BlakeMcKenna
asked on
VB.Net 2005 - FileListBox, DriveListBox, DirectoryListBox Controls Question?
I am using the VB6 FileListBox, DriveListBox, and DirectoryListBox controls in my VB.Net 2005 app. I have the filter set on the FileListBox. What I need to do is select all the files in the FileListBox using my app without the users interaction. I then wish to process each selected file in a for loop. I'm just not sure what properties/methods to use for the FileListBox.
Please help!
Thanks,
Blake
Please help!
Thanks,
Blake
ASKER
I just want to open them and process the data. I just wasn't sure how to select them or if I needed to. However, the ListCount property should work.
Thanks,
Thanks,
ASKER
Actually, there is no listcount property. At least I didn't see one thru intellisense!
Those controls have been "updated" to be more consistent with .Net syntax so they have an Items() collection now...
Public Class Form1
Private Sub FormC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FileListBox1.Path = "c:\"
FileListBox1.Pattern = "*.txt"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To FileListBox1.Items.Count - 1
FileListBox1.SelectedIndex = i
Application.DoEvents()
Debug.Print(FileListBox1.I tems(i))
System.Threading.Thread.Sl eep(250) ' simulated processing
Next
MsgBox("Done!")
End Sub
End Class
Public Class Form1
Private Sub FormC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FileListBox1.Path = "c:\"
FileListBox1.Pattern = "*.txt"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To FileListBox1.Items.Count - 1
FileListBox1.SelectedIndex
Application.DoEvents()
Debug.Print(FileListBox1.I
System.Threading.Thread.Sl
Next
MsgBox("Done!")
End Sub
End Class
ASKER
How do I reference the filename?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You should be able to simply loop through them...
Dim x As Int16
For x = 0 To File1.ListCount - 1
Console.WriteLine File1.List(x)
Next