请问internet transfer高手下边的代码!

bitcat 2001-12-11 11:12:27
为什么总是提示出错“在执行上一条操作”,当再次双击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
...全文
43 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧