用程序选中第二项 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
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
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
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
listbox每次新加入文件都会产生一个newindex
List1.ListIndex = List1.NewIndex 即可选中新加入得文件