250分最高分,再次求将RichTextBox中显示的c:\888.GIF处理成显示图像

来源:百度知道 编辑:UC知道 时间:2024/06/16 18:58:46
VB中RichTextBox内的文本"c:\888.GIF",如何处理成显示图像?

求源代码.
不是复制和粘贴图片,也不是WebBrowser调用,是将图像路径处理成显示图像.

所谓再次,是前面还有一个同样的问题,所以实际总分是450分.

求源代码.

就像HTML中的标记那样,将字符串"c:\888.GIF"变成<IMG SRC=c:\888.GIF>,可以浏览器中显示图像.不过这不是在浏览器显示图像,而是在RichTextBox中显示已有字符串c:\888.GIF的图像(将c:\888.GIF变成一幅图像).

文本字符为#^c:\888.bmp^
表示显示C:\888.bmp

新建一个richtextbox,命名为temp
在richtextbox1里输入,
解释后的结果在2里

Option Explicit
Dim t1, t2 As String, i, p, t As Long
Function convstr(str As String) As String
On Error Resume Next
Dim i As Long
convstr = ""
For i = 1 To Len(str)
If (i = 1) Or (Mid(str, i, 1) <> "\") Then
convstr = convstr + Mid(str, i, 1)
End If
If (i > 1) Then
If (Mid(str, i, 1) = "\") And (Mid(str, i - 1, 1) <> "\") Then convstr = convstr + Mid(str, i, 1)
End If
Next
End Function
Sub addimg()
On Error Resume Next
temp.TextRTF = ""
Debug.Print
temp.OLEObjects.Add , , convstr(Mid(t1, t + 2, i - t - 2))
t2 = t2 + temp.TextRTF
End Sub
Private Sub Command1_Click()
On Error Resume Next
With RichTextBox2
t1 = RichTextBox1.Text