Last modified on 22 March 2006, at 12:03

Coding Cookbook/Inline If

Not every language offers an Inline If function.

VBScript solutionEdit

function IIf (boolValue, varTrue, varFalse)  ' Inline If
  if boolValue then IIf = varTrue else IIf = varFalse
  end function

strFoo = IIf( 1>2, "x", "y" ) ' result: strFoo = "y"