Coding Cookbook/Inline If

From Wikibooks, open books for an open world
< Coding Cookbook
Jump to: navigation, search

Not every language offers an Inline If function.

[edit] VBScript solution

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"
Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export