How to do multiple conditions for single If statement

James Drinkard picture James Drinkard · Sep 20, 2011 · Viewed 283.9k times · Source

I'm trying to do two conditions on a single If statement in vbscript. Should be really simple, but it's not working. Something like:

 If Not (fileName = testFileName) & (fileName <> "") Then
Else ....

I'm making it two if statements to get it working, but can I do a not conditional with an "and" with another not condition?

Answer

Hogan picture Hogan · Sep 20, 2011

Use the 'And' keyword for a logical and. Like this:

If Not ((filename = testFileName) And (fileName <> "")) Then