...

View Full Version : A substitue for IIF(expr,Tue,False)?



ScottInTexas
09-06-2004, 04:04 PM
I would like to avoid using

If expr Then
Something
Else
Something Else
End If

I was sure there was something but I can't find a reference for it and nothing I tried is working.

Thanks for your help.

BuddhaMan
09-06-2004, 08:34 PM
"Select Case" maybe? (Not sure if you know about this one or this is what you're wanting.)

http://www.devguru.com/Technologies/vbscript/quickref/selectcase.html

glenngv
09-07-2004, 07:48 AM
You can use a normal If...Then...Else statement in a single line without EndIf.

Visual Basic:
CheckIt = IIf(TestMe > 1000, "Large", "Small")

VBScript:
If TestMe > 1000 Then CheckIt = "Large" Else CheckIt = "Small"

ScottInTexas
09-07-2004, 01:57 PM
Thanks Glenn,
I didn't know I could use an Else in the same line. I should have. Maybe just an old habit of putting it in a block. I ended up doing it the way I didn't want to just so I could move on. I can go back and change those lines now. The reason? It just looks cleaner.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum