OR Statement

  • Thread starter Thread starter Seelan Rajagopal
  • Start date Start date
S

Seelan Rajagopal

Hey Guys!
I am a newbie to VB.net
can some one show me how to add OR statements in IF..Then condition?

This is the code I'm using
If NOT (myFile.PostedFile.ContentType) <> "application/msword" Then
....

I want to add OR statements to include these types as
well...."application/ms-excel", "...", "..."
 
Hi Seelan,

The logical Or, they have found a new word for that, they call it orelse it
can be used as
\\\
if a=b orelse a=c orelse a=d orelse a=e
'do something
end if
///
\\\
You can to use like normal people
if a=b or a=c or a=d or a=e
'do something
end if
///
But that is a little bit slower.

But it's easier in the sisuation you were telling to use
\\\
select case a
case b,c,d,e
'do something
end select
///
I hope this helps a bit.
Cor
 
.. . .
how to add OR statements in IF..Then condition? .. . .
If NOT (myFile.PostedFile.ContentType) <> "application/msword" .. . .
I want to add OR statements to include these types as
well...."application/ms-excel", "...", "..."

As soon as you start looking at more than one comparison on the
/same/ thing in an If, start looking at Select Case, something like :

Select Case myFile.PostedFile.ContentType
Case "application/msword", "application/ms-excel", "...", "..."
' Word, Excel, or whatever
Case Else
' Something completely different
End Select

HTH,
Phill W.
 
Thanks Cor and Phill
It works!!!

Phill. W said:
. . .

As soon as you start looking at more than one comparison on the
/same/ thing in an If, start looking at Select Case, something like :

Select Case myFile.PostedFile.ContentType
Case "application/msword", "application/ms-excel", "...", "..."
' Word, Excel, or whatever
Case Else
' Something completely different
End Select

HTH,
Phill W.
 
Hi Cor/Seelan, OrElse is logical only, and it is Short-Circuited.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
Hi Tom,
I know as logical operators exist Or and OrElse; As bitwise operator only
Or.
:-)
Cor
 
Back
Top