Thursday, May 27, 2010

Search for text files in your drives and display them

This program let you choose your drives and folders and displays all the text files from the chosen folder in a list box. You need to place a combo box, a DriveListBox, a DirListbox and a Listbox into your form.
The code is as follows:

Private Sub Form_Load()
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
Combo1.Text = "All Text Files"
Combo1.AddItem "All Text Files"
Combo1.AddItem "All Files"
End Sub

Private Sub Combo1_Change()
If ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else
Fiel1.Pattern = ("*.*")
End If
End Sub


Private Sub Dir1_Change()
File1.Path = Dir1.Path
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else

File1.Pattern = ("*.*")
End If
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.txt")
Else
File1.Pattern = ("*.*")
End If

If Right(File1.Path, 1) <> "\" Then
filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
Text1.Text = filenam
End Sub

No comments:

Post a Comment