2
我有下面的代碼,查找顯示在組合框中的值,然後填充與所選擴展名相關的選定文件名的列表框(也許代碼會更有意義!)添加多個擴展到字符串VB.net
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim lyxfle As New IO.DirectoryInfo(sPath)
Dim diar1 As IO.FileInfo() = lyxfle.GetFiles()
Dim MyExt As String = Nothing
Dim MyVariable As String
Dim sFile As String
MyVariable = ComboBox1.Text
If MyVariable = "Forms" Then MyExt = "*.pff"
If MyVariable = "Reports" Then MyExt = "*.mdb"
If MyVariable = "Spreadsheets" Then MyExt = "*.xlsm"
ListBox2.Items.Clear()
sFile = Dir$(sPath & MyExt)
Do While CBool(Len(sFile))
ListBox2.Items.Add(System.IO.Path.GetFileNameWithoutExtension(sFile))
sFile = Dir$()
Loop
End Sub
下面這行就是我與
If MyVariable = "Spreadsheets" Then MyExt = "*.xlsm"
基本上,我需要它來也看看擴展掙扎.XLS &的.xlsx,包括列表
中的所有文件兩個路徑和SPATH在類
任何意見
我可能會溝DIR $命令做到這一點:http://stackoverflow.com/questions/163162/可任您呼叫目錄的GetFiles與 - 多濾波器 – WozzeC
感謝您的鏈接,但是是非常新的,以VB(本週)我掙扎,如何實現換到DIR $命令 – elmonko