VB中Image1.picture的问题
(如图)我把一个图片的地址写入文本文档1.txt中,怎么才能让Image1.picture=1.txt中的地址(希望有具体的代码和方法,谢谢)...
(如图)我把一个图片的地址写入文本文档1.txt中,怎么才能让Image1.picture=1.txt中的地址(希望有具体的代码和方法,谢谢)
展开
3个回答
展开全部
1) 保存 D:\1.Txt 文件程序如下:
Dim FileNum As Long
Dim fileName As String
fileName = "D:\1.Txt"
FileNum = FreeFile()
Open fileName For Output As FileNum
Print #FileNum, "C:\Document and Setting\Administrator\桌面\psb.pjg"
Close FileNum
2) Image 装载图片文件
Dim FileNum As Long
Dim fileName As String
Dim tmpStr As String
fileName = "D:\Txt\1.Txt"
FileNum = FreeFile()
Open fileName For Input As FileNum
Line Input #FileNum, tmpStr
Close FileNum
If Len(Dir$(tmpStr))=0 Then
MsgBox "文件:"+tmpStr +" 不存在!"
Exit Sub
End If
Image.Picture=LoadPicture(tmpStr)
Dim FileNum As Long
Dim fileName As String
fileName = "D:\1.Txt"
FileNum = FreeFile()
Open fileName For Output As FileNum
Print #FileNum, "C:\Document and Setting\Administrator\桌面\psb.pjg"
Close FileNum
2) Image 装载图片文件
Dim FileNum As Long
Dim fileName As String
Dim tmpStr As String
fileName = "D:\Txt\1.Txt"
FileNum = FreeFile()
Open fileName For Input As FileNum
Line Input #FileNum, tmpStr
Close FileNum
If Len(Dir$(tmpStr))=0 Then
MsgBox "文件:"+tmpStr +" 不存在!"
Exit Sub
End If
Image.Picture=LoadPicture(tmpStr)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Open App.Path & "\1.txt" For Binary As #1
Image1.Picture = LoadPicture(Input(LOF(1), #1))
Close #1
Image1.Picture = LoadPicture(Input(LOF(1), #1))
Close #1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询