首先,在新建的窗体中放一个Image控件。 然后把下面的代码复制到代码里。'用来下载文件的API函数 Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As LongPrivate Sub Form_Load() '将图片下载到本地硬盘 URLDownloadToFile 0, "网络图片地址", "下载到硬盘的地址(如c:\1.jpg)", 0, 0 '设置image控件的picture属性显示该图片 Image1.Picture = LoadPicture("c:\test.jpg") End Sub
Private Sub Command1_Click() If Inet1.StillExecuting Then Exit Sub Inet1.Execute "http://passport.csdn.net/ShowExPwd.aspx?temp=", "GET"'改为QQ验证码网页地址试一试,现在是CSDN End Sub Private Sub Inet1_StateChanged(ByVal State As Integer) If State = icResponseCompleted Then Dim BinBuff() As Byte Dim StrPath As String StrPath = "c:\123.jpg" BinBuff = Inet1.GetChunk(0, icByteArray) If Dir(StrPath) <> "" Then Kill StrPath Open StrPath For Binary As #1 Put #1, , BinBuff Close #1 Set Picture1.Picture = LoadPicture(StrPath) End If End Sub
然后把下面的代码复制到代码里。'用来下载文件的API函数
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As LongPrivate Sub Form_Load()
'将图片下载到本地硬盘
URLDownloadToFile 0, "网络图片地址", "下载到硬盘的地址(如c:\1.jpg)", 0, 0
'设置image控件的picture属性显示该图片
Image1.Picture = LoadPicture("c:\test.jpg")
End Sub
你可以看这个
你可以看这个
If Inet1.StillExecuting Then Exit Sub
Inet1.Execute "http://passport.csdn.net/ShowExPwd.aspx?temp=", "GET"'改为QQ验证码网页地址试一试,现在是CSDN
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = icResponseCompleted Then
Dim BinBuff() As Byte
Dim StrPath As String
StrPath = "c:\123.jpg"
BinBuff = Inet1.GetChunk(0, icByteArray)
If Dir(StrPath) <> "" Then Kill StrPath
Open StrPath For Binary As #1
Put #1, , BinBuff
Close #1
Set Picture1.Picture = LoadPicture(StrPath)
End If
End Sub