Ahmadal_najjar2003
asked on
Can Contains Property Have many items(VB2008)
Salam
I have this code
if itm.Contains(".jpg") Or itm.Contains(".png") Or itm.Contains(".bmp") Or itm.Contains(".mpg") Or itm.Contains(".wmv")
' some code here
End If
Can contains be multible instead of using Or.
Ahmad Al-najjr
I have this code
if itm.Contains(".jpg") Or itm.Contains(".png") Or itm.Contains(".bmp") Or itm.Contains(".mpg") Or itm.Contains(".wmv")
' some code here
End If
Can contains be multible instead of using Or.
Ahmad Al-najjr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To add the other file types change this line of code:
Dim itmFound As List(Of String) = itm.FindAll(Function(f) Regex.IsMatch(f, "(jpg|png|bmp|mpg|wmv)"))
To this:
Dim itmFound As List(Of String) = itm.FindAll(Function(f) Regex.IsMatch(f, "\.(jpg|png|bmp|mpg|wmv|mp4|avi|mp3)"))
ASKER
thank you
Not a problem, glad to help. ;=)
ASKER
Dim MyFilesExt() As String = {".jpg", ".bmp", ".png", ".mpg", ".wmv", ".mp4", ".avi", ".mp3"}
' Now get file Extention .
For i As Integer = 0 To MyFilesExt.Count - 1
If itm.Contains(MyFilesExt(i)
ListBox1.Items.Add(itm)
End If
Next