|
在 statechanged 事件里,您可以使用Select
Case…End Select陈述句通知用户有关连线的状态。程序如下:
Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case icError
MsgBox Inet1.ResponseInfo, , "File failed to transfer"
Case icResolvingHost
Label6.Caption = "Resolving Host"
Case icHostResolved
Label6.Caption = "Host Resolved"
Case icConnecting
Label6.Caption = "Connecting Host"
Case icConnected
Label6.Caption = "Host connected"
Case icReceivingResponse
Label6.Caption = "Receiving Response"
Case icResponseReceived
Label6.Caption = "Got Response"
Case icResponseCompleted
Dim
data1 As String
Dim
data2 As String
MsgBox "Download Completed"
End
Select
End
Sub
在FTP
程式里,我建立了一个表单和一个对话框。对话框中可以通过按一下该项目菜单栏上来添加,然后在下拉式清单中选择添加表格上的项目。您可以选择一般的对话框,或登录对话框。该对话框是用来接受FTP地址,用户名和密码,然后连接到伺服器器。成功登录后,对话框中将会隐藏而主要表单将被提交供用户浏览远程目录,并选择下载某些文件。

|
登录对话框的程式:
Option Explicit
Private Sub
OKButton_Click()
Inet1.URL =
Text1.Text
Inet1.UserName =
Text2.Text
Inet1.Password =
Text3.Text
Inet1.Execute ,
"DIR"
Form1.Show
Dialog.Hide
End Sub
Private Sub
Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case icError
MsgBox
Inet1.ResponseInfo, , "File failed to transfer"
Case
icResolvingHost
Label6.Caption =
"Resolving Host"
Case icHostResolved
Label6.Caption =
"Host Resolved"
Case icConnecting
Label6.Caption =
"Connecting Host"
Case icConnected
Label6.Caption =
"Host connected"
Case
icReceivingResponse
Label6.Caption =
"Receiving Response"
Case
icResponseReceived
Label6.Caption =
"Got Response"
Case
icResponseCompleted
Dim data As String
Dim data1 As String
MsgBox "Transfer
Completed"
Do
data1 = Inet1.GetChunk(1024, icString)
data = data & data1
Loop While Len(data1) <> 0
Form1.Text6.Text = data
End Select
End Sub
Private Sub
CancelButton_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
FTP 主要界面

|