Rob Eberhardt

cleverness ensues

skip navigation

 Thursday, May 25, 2006

I add a custom IIF function to every VBscript I make:

' IIF recreated for VBscript
FUNCTION IIF(Expression, Truepart, Falsepart)
	IF Expression THEN 
		IIF = Truepart
	ELSE
		IIF = Falsepart
	END IF
END FUNCTION

'used like so:
strFlavor = IIF(strColor="brown", "chocolate", "not chocolate")

Mind you, it evaluates all parameters on the way in, so even though this checks the objTest object when assigning using it, it would still fail (when the objTest object reference is not set):

strFlavor = IIF(IsObject(objTest), objTest.flavor, "vanilla")

It's no ternary operator, but it's still indispensible for efficient VBScript coding.

5/25/2006 6:21 PM Eastern Daylight Time  #    Disclaimer  |  Comments [5]  | 
Tracked by:
http://www.google.com/search?q=ankchmqy [Pingback]
http://www.google.com/search?q=uirzfhqz [Pingback]
http://kitaabghar.com/dir/javascript/2/buyvaliumonline.htm [Pingback]
http://inlay.com/phpBB/cache/misc/c/ultram-online.htm [Pingback]
http://getindyknow.com/components/com_mymenu/1/weight-loss-program.htm [Pingback]
http://getindyknow.com/components/com_mymenu/4/phentermine-adipex.htm [Pingback]
http://shining.com/store/ph/c/valium.htm [Pingback]
http://www.eea-esem2006.org/fileadmin/c/vicodin.htm [Pingback]
http://inlay.com/phpBB/cache/misc/c/buyvaliumonline.htm [Pingback]
http://shining.com/store/ph/c/diet-pills.htm [Pingback]
http://alsysinc.com/images/Image/c/buy-phentermine-online.htm [Pingback]
http://localboard.on.ca/GuestBook/public/d/phentermine-adipex.htm [Pingback]
http://alsysinc.com/images/Image/b/spywaredoctor.htm [Pingback]
http://helpthemknow.com/phplist/attachments/c/best-diet-pills.htm [Pingback]
http://localboard.on.ca/GuestBook/public/a/buy-propecia.htm [Pingback]
http://localboard.on.ca/GuestBook/public/b/phentermine-prescription.htm [Pingback]
http://www.ballunspitze.com/captcha/c/ephedra-diet-pill.htm [Pingback]
http://inlay.com/phpBB/cache/misc/b/meridiaonline.htm [Pingback]
http://inlay.com/phpBB/cache/misc/d/hydrocodone-online.htm [Pingback]
http://www.dezwei.at/coppermine/albums/b/order-propecia.htm [Pingback]
http://www.ballunspitze.com/captcha/c/levitrabuy.htm [Pingback]
http://www.eea-esem2006.org/fileadmin/d/diet.htm [Pingback]
http://alsysinc.com/images/Image/d/weight-loss-tip.htm [Pingback]
http://www.eea-esem2006.org/fileadmin/c/weight-loss.htm [Pingback]
http://inlay.com/phpBB/cache/misc/d/atkinsdiet.htm [Pingback]
http://getindyknow.com/components/com_mymenu/2/meridia-online.htm [Pingback]
http://getindyknow.com/components/com_mymenu/1/buy-propecia.htm [Pingback]
http://localboard.on.ca/GuestBook/public/d/diet-plan.htm [Pingback]
http://www.google.com/search?q=lvxkatue [Pingback]
http://www.google.com/search?q=stjatrys [Pingback]
http://www.google.com/search?q=bnnixptb [Pingback]
http://www.google.com/search?q=qhlroxxy [Pingback]
http://zavernuli.0catch.com/246.html [Pingback]
http://narubili.freehostia.com/594.html [Pingback]
8/23/2006 11:20:04 PM (Eastern Daylight Time, UTC-04:00)
12/13/2006 3:56:35 AM (Eastern Standard Time, UTC-05:00)
qwe
12/13/2006 3:57:20 AM (Eastern Standard Time, UTC-05:00)
Hello
12/13/2006 3:58:45 AM (Eastern Standard Time, UTC-05:00)
Hello
9/18/2007 12:44:19 PM (Eastern Daylight Time, UTC-04:00)
Although the remarks above state that the IIf function is a counterpart the for C++ (and C#) ternary conditional operator (?:); it has does not have the same semantics.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):