Share via


Visual Basic for Applications Reference

Comparison Operators Example

This example shows various uses of comparison operators, which you use to compare expressions.

  Dim MyResult, Var1, Var2
MyResult = (45 < 35)   ' Returns False.
MyResult = (45 = 45)   ' Returns True.
MyResult = (4 <> 3)   ' Returns True.
MyResult = ("5" > "4")   ' Returns True.

Var1 = "5": Var2 = 4   ' Initialize variables.
MyResult = (Var1 > Var2)   ' Returns True.

Var1 = 5: Var2 = Empty
MyResult = (Var1 > Var2)   ' Returns True.

Var1 = 0: Var2 = Empty
MyResult = (Var1 = Var2)   ' Returns True.