日期:2012-11-26  浏览次数:20756 次

这是控件的源程序:
工程名:MY
控件名:TESTFTP

Dim FileName As String
Dim connect As Boolean


Private Sub CmdCd_Click()

  Call Link
  'Inet1.Execute , "cd c2000"
  connect = True
   
End Sub

Private Sub CmdList_Click()

  If connect = True Then
    Inet1.Execute , "LS"
  Else
    Label1.Caption = "please click connect first!"
  End If

End Sub


Private Sub Combo1_Click()
  
  FileName = Combo1.Text 'file name of download file

End Sub

Private Sub CmdDown_Click()

  Dim FileLast As String 'last name of file
  Dim SaveFileName As String 'file name in ftpserver
  Call Link
  
  If FileName = "" Then
    Label1.Caption = "please select file to download!"
  Else
    FileLast = ""
    For i = 1 To Len(FileName)
      If Mid(FileName, i, 1) <> "." Then
        FileLast = FileLast + Mid(FileName, i, 1)
      Else
        FileLast = ""
      End If
    Next
REDO:     CommonDialog1.ShowSave

    If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
      Label1.Caption = "The file can't include space!"
      MyVar = MsgBox("Redo it?", 65, "Download file")
      If MyVar = "1" Then
        GoTo REDO:
      Else
        GoTo NODO:
      End If
    End If
    
    SaveFileName = CommonDialog1.FileName & "." & FileLast
    Inet1.Execute , "GET " & FileName & " " & SaveFileName
  End If
NODO:

End Sub

Private Sub CmdUpload_Click()
  
  Dim SaveFileName As String
  Dim UpFileName As String 'file name of upload file include path
  Dim MyVar
  SaveFileName = ""
  Call Link
  
REDO:  CommonDialog1.ShowOpen

  If InStr(1, CommonDialog1.FileName, " ", 1) > 0 Then
    MsgBox "The file can't include space!"
    MyVar = MsgBox("Redo it?", 65, "Upload file")
    If MyVar = "1" Then
      GoTo REDO:
    Else
      GoTo NODO:
    End If
  End If
  
  UpFileName = CommonDialog1.FileName
  'MsgBox UpFileName
  
  For i = 1 To Len(UpFileName)
    If Mid(UpFileName, i, 1) <> "\" Then
      SaveFileName = SaveFileName + Mid(UpFileName, i, 1)
    Else
      SaveFileName = ""
    End If
  Next
  
  If SaveFileName = "" Then
    La