How to use Comparison Operators in VBA?

Comparison operators compare the contents in a field to either the contents in another field or a constant. They may be used alone or in combination with other operators and functions in both record expressions and target field expressions.

Private Sub Constant_demo_Click()
   Dim a: a = 10
   Dim b: b = 20
   Dim c

   If a = b Then
      MsgBox ("Operator Line 1 : True")
   Else
      MsgBox ("Operator Line 1 : False")
   End If

   If a<>b Then
      MsgBox ("Operator Line 2 : True")    
   Else
      MsgBox ("Operator Line 2 : False")    
   End If

   If a>b Then
      MsgBox ("Operator Line 3 : True")    
   Else
      MsgBox ("Operator Line 3 : False")    
   End If

   If a<b Then
      MsgBox ("Operator Line 4 : True")    
   Else
      MsgBox ("Operator Line 4 : False")    
   End If

   If a>=b Then
      MsgBox ("Operator Line 5 : True")    
   Else
      MsgBox ("Operator Line 5 : False")    
   End If

   If a<=b Then
      MsgBox ("Operator Line 6 : True")
   Else
      MsgBox ("Operator Line 6 : False")
   End If

End Sub

When you execute the above script, it will produce the following result.

Operator Line 1 : False

Operator Line 2 : True

Operator Line 3 : False

Operator Line 4 : True

Operator Line 5 : False

Operator Line 6 : True