I have the below code that looks for the value displayed in a combobox then populates a listbox with the selected file names that relate the extension selected (maybe the code will make more sense!)
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
The following line is what i'm struggling with
If MyVariable = "Spreadsheets" Then MyExt = "*.xlsm"
I basically need it to also look at the extensions .xls & .xlsx and include all files within the list
Both Path and sPath are declared as Private Strings at the top of the class
Any advice