利用VB实现FTP基本功能(3)

2019-03-16 13:19

武汉理工大学《计算机网络》课程设计说明书

Case \ mnuRename_Click Case \ lvListView.View = lvwIcon Case \

lvListView.View = lvwSmallIcon Case \

lvListView.View = lvwList Case \

lvListView.View = lvwReport End Select End Sub

Private Sub mnuFileClose_Click() 'unload the form Unload Me End Sub

Public Function FormatFileSize(lFileSize As Long) As String On Error GoTo ERROR_HANDLER If lFileSize >= 1024 Then

FormatFileSize = Format$(CStr(lFileSize / 1024), \### ### KB\'CStr 转换为String类型 Else

FormatFileSize = CStr(lFileSize) & \ End If Exit Function ERROR_HANDLER:

Debug.Print Err.Number & \End Function

Private Sub tvTreeView_DragDrop(Source As Control, x As Single, y As Single) 'source只正在

10

武汉理工大学《计算机网络》课程设计说明书

被拖动的控件,x,y指鼠标指针在目标对象中的坐标值 If Source = imgSplitter Then SizeControls x End If End Sub

Private Sub AddFileToListView(oFtpFile As CFtpFile) Dim intIcon As Integer Dim strFileName As String strFileName = oFtpFile.FileName intIcon = GetImageNumber(strFileName)

Set lvItem = lvListView.ListItems.Add(, strFileName, strFileName, intIcon, intIcon) lvItem.SubItems(1) = oFtpFile.FileSize lvItem.SubItems(2) = oFtpFile.LastWriteTime End Sub

Private Sub RefreshDirectory()

With tvTreeView.SelectedItem '从treeview中移除所有subfolders If .Children > 0 Then For i = 1 To .Children

tvTreeView.Nodes.Remove (.Child.Index) Next i End If

lvListView.ListItems.Clear ListFiles tvTreeView.SelectedItem End With End Sub

Private Sub EstablishConnection() Dim tvNode As Node Dim f As New frmConnect

f.Show vbModal '显示连接窗体的内容

11

武汉理工大学《计算机网络》课程设计说明书

If f.Action = comdOK Then '当按下OK时,清空treeview和listview的内容 tvTreeView.Nodes.Clear lvListView.ListItems.Clear With m_FtpConnection .FtpServer = f.URL .UserName = f.UserName .Password = f.Password

.PassiveMode = CBool(Check1.Value) 'call Connect method If .Connect Then Label1 = f.URL

'add root node to the treeview

Set tvNode = tvTreeView.Nodes.Add(, , , .CurrentDirectory, 1) tvNode.Key = .CurrentDirectory Set tvTreeView.SelectedItem = tvNode ListFiles tvNode, True End If '.Connect End With 'm_FtpConnection End If 'f.Action = comdOK End Sub

5.2.2 frmconnect窗体的部分代码

Public Property Get UserName() As String UserName = mvarUserName End Property

Public Property Get Password() As String Password = mvarPassword End Property

Public Property Get URL() As String URL = mvarURL

12

武汉理工大学《计算机网络》课程设计说明书

End Property

Private Sub chkAnonym_Click() If chkAnonym.Value Then txtUserName = \ txtPassword.PasswordChar = \ txtPassword = \ Frame3.Caption = \Else txtUserName = \

txtPassword.PasswordChar = \ txtPassword = \

Frame3.Caption = \End If End Sub

Private Sub cmdCancel_Click() mvarAction = comdCancel Unload Me End Sub

Private Sub cmdOK_Click() If Len(txtURL) = 0 Then

MsgBox \URL\ Exit Sub

Else mvarURL = LCase(txtURL.Text) End If

If Len(txtUserName.Text) = 0 Then mvarUserName = vbNullString

Else mvarUserName = txtUserName.Text End If

If Len(txtPassword.Text) = 0 Then

13

武汉理工大学《计算机网络》课程设计说明书

mvarPassword = vbNullString Else mvarPassword = txtPassword.Text End If

mvarAction = comdOK Unload Me End Sub

Public Property Let Action(ByVal vData As Command) mvarAction = vData End Property

Public Property Get Action() As Command

'used when retrieving value of a property, on the right side of an assignment. 'Syntax: Debug.Print X.Action Action = mvarAction End Property

5.2 运行结果

5.2.1 开始界面(见图一)

(图一)

14


利用VB实现FTP基本功能(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:修辞句子大全

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: