Thread: IIf
View Single Post
Old June 12th, 2007, 11:31 AM
BrianWren BrianWren is offline
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

You really can find all of the answers to the basic questions you have been asking in VB Help...

IIf is a single-statement If for returning a value. It takes three arguments. If the first argument is true, it returns the 2nd argument. If the 1st argument is false, it returns the 3rd argument.
   Dim s as String

   s = IIf( (2 + 2) = 4, "It is True", "It is False")

   ' The above results in exactly the same result as the below.

   If (2 + 2) = 4 Then
      s = "It is True"
      s = "It is False"
   End If