Visual Basic includes the Immediate If function (IIf), but VBScript (VBS) does not. However, you can copy this code to VBS to allow the IIf function to be used:
'VB Function not included in VBSFunction IIf(Expression, TruePart, FalsePart) If Expression = True Then If IsObject(TruePart) Then Set IIf = TruePart Else IIf = TruePart End If Else If IsObject(FalsePart) Then Set IIf = FalsePart Else IIf = FalsePart End If End IfEnd Function
The function can return both objects and basic data types. Heres a sample function from an ASP page that calls the IIf function:
' Return a True or False value for a checkboxFunction CheckBoxValue(Name) CheckBoxValue = _ IIf(Request.Form(Name) = "on", True, False)End Function