'部件里添加 Microsoft Internet Transfer Control 6.0
'1.下载网页
Private Sub Command1_Click()
Dim s As String
Inet1.Cancel
Inet1.protocol = icHTTP
Inet1.url = "http://www.baidu.com"
s = Inet1.OpenURL
If Len(s) = 0 Then Exit Sub
Open "d:/aaa.htm" For Output As #1
Print #1, s
Close #1
MsgBox "ok"
End Sub
'2.下载图片
Private Sub Command1_Click()
Dim myData() As Byte, i&, myURL$, RealFile$
myURL = "http://www.baidu.com/img/baidu_logo.gif"
If Inet1.StillExecuting = True Then Exit Sub
myData() = Inet1.OpenURL(myURL, icByteArray)
For i = Len(myURL) To 1 Step -1
If Left$(Right$(myURL, i), 1) = "/" Then RealFile$ = Right$(myURL, i - 1)
Next
Open "d:/1.gif" For Binary Access Write As #1
Put #1, , myData()
Close #1
Picture1.Picture = LoadPicture("d:/1.gif")
End Sub
Private Sub Form_Load()
Picture1.AutoSize = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Dir("d:/1.gif") <> "" Then Kill "d:/1.gif"
End Sub