VB遍历文件问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 19:03:38
我想提取c:\mic里所有音乐文件,并把名称输入label中
比如有2个文件a.mp3,b.mp3,我想在提取这2文件并在label中显示"a.mp3 b.mp3"
请说明详细用法,这样解释我不明白

用FileListBox不就可以很轻松的搞定了吗?

在窗体上画一个 CommandButton 一个 TextBox 和一个FileListBox

Private Sub Command1_Click()
Dim F As Integer
For F = 0 To File1.ListCount - 1
Text1.Text = File1.List(F) & " " & Text1.Text
Next
End Sub

Private Sub Form_Load()
Text1.Text = ""
Command1.Caption = "用FileBox遍历文件"
File1.Path = "C:\mic"
File1.Pattern = "*.Mp3;*.Wav;*.Wma;*.Mid"
File1.Hidden = True
File1.System = True
End Sub

FindFirstFile 和FindNextFile 两个api函数,自己在百度输入函数名搜索就知道怎么用了。