dim st,xmldoc,iPic set st = CreateObject("adodb.stream") st.Type=1 st.Open st.loadFromFile "F:\index_a0b1.gif"'你要转换的图片 set xmldoc = CreateObject("Microsoft.XMLDOM") xmldoc.loadXML "<?xml version=""1.0""?><root/>" set iPic = xmldoc.createElement("pic") iPic.dataType = "bin.base64" iPic.nodeTypedValue = st.Read(-1) xmldoc.documentElement.appendChild iPic xmldoc.save App.Path & "pic.xml"
标准exe,一个PictureBox控件 Private Sub Form_Load() Dim xmldoc As Object Set xmldoc = CreateObject("Microsoft.XMLDOM") xmldoc.async = False xmldoc.Load "F:\http\formo\club\image.xml" If xmldoc.parseError.errorCode Then MsgBox "loading error!" Else Dim temp_image() As Byte Dim temp_file As String Dim a Set a = xmldoc.documentElement.selectSingleNode("pic") If TypeName(a) = "Nothing" Then MsgBox "节点不存在!" Else temp_image() = a.nodeTypedValue temp_file = App.Path & "temp.gif" Open temp_file For Binary As #1 Put #1, , temp_image() Close #1 Picture1.Picture = LoadPicture(temp_file) Kill temp_file End If End If End Sub
set st = CreateObject("adodb.stream")
st.Type=1
st.Open
st.loadFromFile "F:\index_a0b1.gif"'你要转换的图片
set xmldoc = CreateObject("Microsoft.XMLDOM")
xmldoc.loadXML "<?xml version=""1.0""?><root/>"
set iPic = xmldoc.createElement("pic")
iPic.dataType = "bin.base64"
iPic.nodeTypedValue = st.Read(-1)
xmldoc.documentElement.appendChild iPic
xmldoc.save App.Path & "pic.xml"
Private Sub Form_Load()
Dim xmldoc As Object
Set xmldoc = CreateObject("Microsoft.XMLDOM")
xmldoc.async = False
xmldoc.Load "F:\http\formo\club\image.xml"
If xmldoc.parseError.errorCode Then
MsgBox "loading error!"
Else
Dim temp_image() As Byte
Dim temp_file As String
Dim a
Set a = xmldoc.documentElement.selectSingleNode("pic")
If TypeName(a) = "Nothing" Then
MsgBox "节点不存在!"
Else
temp_image() = a.nodeTypedValue
temp_file = App.Path & "temp.gif"
Open temp_file For Binary As #1
Put #1, , temp_image()
Close #1
Picture1.Picture = LoadPicture(temp_file)
Kill temp_file
End If
End If
End Sub