Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Retrieve Files From File List Box
Author:
Robson Mukubvu
E-mail:
Click to e-mail author
Submitted:
11/1/2003
Version:
VB6
Compatibility:
VB6
Category:
Controls
Views:
16043
Retrieve files from file list box. For use when developing an mp3 player or extracting file name properties without using APIs
Declarations:
u need to put 2 listboxes on a form 'name them list1 and list2 'a drivelistbox,filelistbox,dirlistbox ' a combobox called combo1 ' a commandbutton command1
Code:
Dim strfile As String Dim path_name As String Private Sub Combo1_Click() File1.Pattern = Combo1.Text End Sub Private Sub Command1_Click() Load_file1 End Sub Private Sub Dir1_Change() File1.FileName = Dir1.path End Sub Private Sub Drive1_Change() Dir1.path = Drive1.Drive End Sub Private Sub Form_Load() Combo1.AddItem "*.xls" Combo1.AddItem "*.dat" Combo1.AddItem "*.wav" Combo1.AddItem "*.mp3" Combo1.AddItem "*.avi" Combo1.AddItem "*.mpg" Combo1.AddItem "*.mov" Combo1.AddItem "*.doc" Combo1.AddItem "*.sql" Combo1.AddItem "*.wma" Combo1.AddItem "*.txt" Combo1.AddItem "*.zip" Combo1.AddItem "*.exe" Combo1.AddItem "*.mpeg" List1.Visible=False End Sub Public Function Load_file1() Dim k As Integer For k = -1 To File1.ListCount If File1.ListIndex = File1.ListCount - 1 Then List1.AddItem File1.FileName k = File1.ListCount End If If File1.ListIndex <> File1.ListCount - 1 And File1.ListIndex <> -1 Then List1.AddItem File1.FileName 'File1.ListIndex = k + 1 End If If k <> File1.ListCount Then File1.ListIndex = k + 1 Next k If File1.ListCount <> 0 Then List1.ListIndex = 0 Then load_list End Function Public Function load_list() Dim i As Integer Dim x_char, y_char As Integer For i = 0 To List1.ListCount If List1.ListIndex = List1.ListCount - 1 Then List1.ListIndex = List1.ListCount - 1 x_char = InStr(1, List1.Text, ".") y_char = Len(List1.Text) - (x_char - 1) strfile = Left(List1.Text, Len(List1.Text) - y_char) List2.AddItem strfile i = List1.ListCount End If If List1.ListIndex <> List1.ListCount - 1 Then x_char = InStr(1, List1.Text, ".") y_char = Len(List1.Text) - (x_char - 1) strfile = Left(List1.Text, Len(List1.Text) - y_char) List2.AddItem strfile List1.ListIndex = i + 1 End If Next i List1.Clear End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement