Many ASP developers are also Visual Basic developers, and as such, we often have
to shift gears between the two, remembering (or trying to remember, at least)
which features exist in one and not the other. Differences in error trapping and
class definitions are among the more well-recognized, but there are many more
subtle discrepancies. For example, VB has a handy function, IIf, which allows
you to collapse several lines of Boolean logic into a single expression, like
this:
blnFoo1 = True
As you can see, the first parameter represents the expression to evaluate. The
second parameter is the result to return if the expression evaluates to True,
while the third parameter is the result to return if the expression evaluates to
False. VBScript, unfortunately, doesn't support this function, but you can
easily write your own equivalent, like this:
blnFoo2 = False
MsgBox IIf(blnFoo1 = blnFoo2, "The same!", "Different!")
Public Function IIf(blnExpression, vTrueResult, vFalseResult)
If blnExpression Then
IIf = vTrueResult
Else
IIf = vFalseResult
End If
End Function
Create an IIF statement in VBScript
By ElementK Journals, published on 18 Jul 2001
| Filed in
You might also like...
VBScript forum discussion
-
MS Edge in Kiosk mode
by kiwi.automate (0 replies)
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
vb script to copy specific file to another computer via local area network
by talekeshav (0 replies)
-
deobfuscate malicious vbscript
by ru5ty (0 replies)
-
How to add parameter into XML file using VBScript
by deepak_solanki19 (0 replies)
VBScript podcasts
-
Hanselminutes: Startup Series: Buying an Existing Small Company or Online Application
Published 8 years ago, running time 0h34m
Scott talks to Rob Walling about how he purchases small niche products and companies online and revitalizes them. He recently purchased an existing product that consisted of a 300 gig database and tens of thousands of lines of Classic ASP. How did he know it was valuable? What's next?
Comments