请教VB inet ftp 连接失败时 就异常退出问题!
小弟用vb 写了一段程序用inet控件去ftp上down文件。 并且生成可执行文件down.exe. 执行down.exe时,如果ftp正常连上没有问题,。
但是如果连接不上时,就会提示 :“运行时错误‘35754',unable to connect to remote host ", 然后我一点击”确定“,整个可执行文件就全部退出了。 现在我想将 35754的错误只是在textbox中show出来,而不需要VB本身弹出上述错误,也不想整个exe程序都因此退出。 我的代码如下,但是还是会产生上述错误。请达人帮忙看,该如何实现呢? 为啥on error goto handler 没用?
Private Sub Execute_Click()
dim sts1 as integer
dim sts2 as integer
With Inet1
.URL = "192.168.1.100"
.Username = "good"
.Password = "bad"
.Execute , "CD d:/home"
sts1 = Inet1.StillExecuting
Do While sts1
sts1 = Inet1.StillExecuting
DoEvents
Loop
If Dir("d:/home/Testdata.log") = "" Then MsgBox ("CAN NOT FIND THE TESTDATA")
.Execute , "GET Testdata.log D:\OLM\data\Testdata.log"
sts2 = Inet1.StillExecuting
Do While sts2
sts2 = Inet1.StillExecuting
DoEvents
Loop
.Execute , "CLOSE"
End With
end sub
'--------------------------------------------
Private Sub Inet1_StateChanged(ByVal State As Integer)
On Error GoTo handler
Select Case State
Case 1
Text1.Text = "is looking"
Text1.Text = "正在查询所指定的主机的 IP 地址"
...... '此段1~10 case 省略,节省版面
Case 11
Text1.Text = "is error"
Text1.Text = "与主机通讯时出现了错误"
Case 12 'icResponseCompleted
Text1.Text = "success receive data"
Text1.Text = "请求已经完成,并且所有数据均已接收到"
End Select
handler:
Select Case Err.Number
Case 35754
Text1.Text = "35754"
Case 35755
Text1.Text = "35755"
Case 35756
Text1.Text = "35756"
Case 35761
Text1.Text = "35761"
Case 35768
Text1.Text = "35768"
End Select
End Sub
[解决办法]
百度到此居然无解