Posted By: mastermine | Jan 6th @ 12:02 PM
page 1 of 1
Comments: 5 | Views: 2578
mastermine
mastermine
See.Hear.Frag
Is there a way of doing the below in vb.net because the Or command will not work with a string.

If diaOpenFile.FileName.ToLower.Contains(".mp3" Or ".wma") Then

Thanks, James
W3bbo
W3bbo
The Master of Baiters
mastermine wrote:
Is there a way of doing the below in vb.net because the Or command will not work with a string.

If diaOpenFile.FileName.ToLower.Contains(".mp3" Or ".wma") Then

Thanks, James

				String filename = diaOpenFile.FileName.ToLower();
Boolean isAudio = filename.EndsWith("mp3") || filename.EndsWith("wma");

if(isAudio) {
   
    // do work
   
}
Or in VB:

Dim filename As String = diaOpenFile.FileName.ToLower();
Dim isAudio As Boolean = filename.EndsWith("mp3") OrElse filename.EndsWith("wma");

If isAudio
   
    ' do work
   
End If


W3bbo
W3bbo
The Master of Baiters
mastermine wrote:
Thanks W3bbo i will give it a go

edit: it works perfectly thanks a lot. Do you want me to credit you in my app


Oh the temptations for stroking my ego!

....but if you feel my (let's face it) insignificant contribution has made a definite improvement to your product feel free.
evildictaitor
evildictaitor
How could you use the adjective "indescribable" truthfully?
Oooh, let's throw in lambda expressions, just for the hell of it:

bool isAudio = (new string[]{ ".mp3", ".wma" }).All(
  x => diaOpenFile.FileName.ToLower.Contains(x) );
Ion Todirel
Ion Todirel
ban...kai
mastermine wrote:
If diaOpenFile.FileName.ToLower.Contains(".mp3" Or ".wma") Then
is diaOpenFile a instance of System.Windows.Forms.OpenFileDialog? if yes you could use the Filter property to filter file types from the start:

diaOpenFile..Filter = "Audio files|*.mp3|*.wma|"
page 1 of 1
Comments: 5 | Views: 2578