Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VBScript
Expertise: Beginner
Nov 5, 2003



Application Security Testing: An Integral Part of DevOps

Use the Immediate If Function in VBScript

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 VBS
Function IIf(Expression, TruePart, FalsePart)
	If Expression = True Then
		If IsObject(TruePart) Then
			Set IIf = TruePart
			IIf = TruePart
		End If
		If IsObject(FalsePart) Then
			Set IIf = FalsePart
			IIf = FalsePart
		End If
	End If
End 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 checkbox
Function CheckBoxValue(Name)
	CheckBoxValue = _
		IIf(Request.Form(Name) = "on", True, False)
End Function
Conrad Sollitt
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date