我做了一个ftp下载程序,我想选中listbox控件中的新文件,都是文本文件.怎么用程序进行自动选择,相当于在界面用鼠标单击文件,请帮忙,在线等待

解决方案 »

  1.   

    用程序选中第二项
    Private Sub Command1_Click()
        List1.ListIndex = 1
    End SubPrivate Sub Form_Load()
        List1.AddItem "aa"
        List1.AddItem "bb"
        List1.AddItem "cc"
        List1.AddItem "dd"
    End Sub
      

  2.   

    Public Sub Download_Click()
    Dim counter As Integer
    Dim fileSize As String
    If Inet1.URL <> "" Then                         ' as long as url is present in box
        While counter < List1.ListCount         ' finds which one is selected in FTP list
            If List1.Selected(counter) = True Then
                If (Left(List1.Text, 2) <> "./" Or Left(List1.Text, 3) <> "../" Or Right(List1.Text, 1) <> "/") Then     ' if not a directory
                    Inet1.Execute , "SIZE " & """" & List1.List(counter) & """"
                    fileSize = fileSize & " bytes.  Do you want to continue?"
                        message.Text = "下载文件: " & List1.List(counter)
                        Inet1.Execute , "GET " & """" & List1.List(counter) & """" & " " & """" & Dir1.Path & "\" & List1.List(counter) & """" ' issues the GET command
                        File2.Refresh
                End If
            End If
            counter = counter + 1               ' moves to next record and tries again
        Wend
    refresh_screen
    File2.Refresh
      

  3.   

    listbox控件中的新文件,你的新文件是怎么加入到listbox中得
    listbox每次新加入文件都会产生一个newindex
    List1.ListIndex = List1.NewIndex 即可选中新加入得文件