请问internet transfer高手下边的代码!
为什么总是提示出错“在执行上一条操作”,当再次双击txtcontent文本框时?
Option Explicit
Public strTempDir As String '定义存储路径字符串
Private Sub Form_Load()
strTempDir = "D:\ftp2\web"
Inet1.UserName = "anonymous"
Inet1.Password = "bitcatwg@yeah.net"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case icError
lblInfo.Caption = Inet1.ResponseCode & "" & Inet1.ResponseInfo
Case icResolvingHost
Case icRequesting
Case icRequestSent
lblInfo.Caption = "正在搜索..."
Case icHostResolved
lblInfo.Caption = "已找到"
Case icReceivingResponse
Case icResponseReceived
lblInfo.Caption = "正在接收数据..."
Case icResponseCompleted
Dim strBuffer As String
strBuffer = Inet1.GetChunk(1024)
If strBuffer <> "" Then
lblInfo.Caption = "完成"
txtContent.Text = strBuffer
Else
lblInfo.Caption = "下载到" & strTempDir & "中"
End If
Case icConnecting
lblInfo.Caption = "正在连接站点..."
Case icConnected
lblInfo.Caption = "连接到站点"
Case icDisconnecting
Case icDisconnected
Case Else
lblInfo.Caption = CStr(State)
End Select
End Sub
Private Sub txtAddress_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(vbCrLf) Then '获取回车响应
KeyAscii = 0 '将键值置零
txtAddress.SelStart = 0 '获取文本起始位置
txtAddress.SelLength = Len(txtAddress) '获取文本长度
On Error GoTo openURLError '设置错误陷阱,见后
Inet1.URL = txtAddress.Text '用文本框给inet1赋值
Inet1.Execute , "DIR" '进行进入目录操作
lblInfo.Caption = Inet1.URL
End If
Exit Sub
openURLError: '错误陷阱处理错误
Select Case Err.Number
Case icBadUrl '找不到站点
lblInfo.Caption = "FTP站点未找到,请输入新地址"
Case icConnectFailed '不能连接到远程主机
Case icConnectionAborted '
Case icCannotConnect
lblInfo.Caption = "连接失败"
Case icInetTimeout
lblInfo.Caption = "连接超时"
Case icExecuting '执行还在上一个请求
Inet1.Cancel '强制关闭当前连接
If Inet1.StillExecuting Then '如果INET1忙,不响应其他请求
lblInfo.Caption = "CANCEL 请求失败"
Else
Resume '继续执行
End If
Case Else
End Select
End Sub
Private Sub txtContent_DblClick()
Dim strDir As String
If txtContent.SelLength Then
If Right(txtContent.SelText, 1) = "/" Then '获取下载目录字符串右起第一字符是否为“/”
txtAddress.Text = txtAddress.Text & "/" & Left(txtContent.SelText, txtContent.SelLength - 1)
'给地址文本框再次赋值
On Error GoTo browseError
strDir = Right(txtAddress.Text, Len(txtAddress.Text) - Len(Inet1.URL))
Inet1.Execute , "Dir" & strDir & "/*"
Else
strDir = Right(txtAddress.Text, Len(txtAddress.Text) - Len(Inet1.URL)) & "/" & txtContent.SelText
strDir = Right(strDir, Len(strDir) - 1)
Inet1.Execute , "get" & strDir & "" & strTempDir & txtContent.SelText
End If
End If
Exit Sub
browseError:
If Err = icExecuting Then
Inet1.Cancel
If Inet1.StillExecuting Then
lblInfo.Caption = "Cancel 请求失败"
Else
Resume
End If
End If
End Sub