vb的inet控制元件,在什么地方可以判斷ip是正確錯誤?在狀態改變函式里沒法判斷啊!
uj5u.com熱心網友回復:
僅供參考:Dim ExeStr As String
Dim Done As Boolean
Private Sub cmd(cmdstr As String)
Do
If Inet1.StillExecuting = False Then Exit Do
Loop
ExeStr = cmdstr
Done = False
Debug.Print ExeStr; "="
Inet1.Execute , ExeStr
Do
DoEvents
If Done Then Exit Do
Loop
End Sub
Public Sub ReadNewWav(wav As String)
Inet1.URL = "ftp://xxx.xxx.xxx.xxx"
Inet1.UserName = "username"
Inet1.Password = "password"
cmd "GET " + wav + ".WAV " + App.Path + "\" + wav + ".WAV"
cmd "QUIT"
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
ReadNewWav ("00000021")
Command1.Enabled = True
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim intFile As Integer
Dim vtData() As Byte
Dim str As String
'On Error GoTo ISCerr
Debug.Print "State="; State,
Select Case State
Case 0
Debug.Print "icNone"
Case 1
Debug.Print "icHostResolvingHost"
Case 2
Debug.Print "icHostResolved"
Case 3
Debug.Print "icConnecting"
Case 4
Debug.Print "icConnected"
Case 5
Debug.Print "icRequesting"
Case 6
Debug.Print "icRequestSent"
Case 7
Debug.Print "icReceivingResponse"
Case 8
Debug.Print "icResponseReceived"
If Left(ExeStr, 2) = "CD" Then Done = True
Case 9
Debug.Print "icDisconnecting"
Case 10
Debug.Print "icDisconnected"
Done = True
Case 11
Debug.Print "icError of [" + ExeStr + "]="; Inet1.ResponseInfo
Done = True
Case 12
Debug.Print "icResponseCompleted----------------"
Do
str = Inet1.GetChunk(1024, icString)
If LenB(str) = 0 Then Exit Do
Debug.Print str
Loop
Done = True
End Select
Exit Sub
ISCerr:
Resume Next
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/88091.html
標籤:VB基礎類
