Comparison Operators

Comparison operators compare two expressions. The result is returned as a boolean expression that determines if the comparison is True (-1) or False (0).

Syntax:


  result = expression1 { = | < | > | <= | >= } expression2

Parameters:

result: Boolean that specifies the result of the comparison (True, or False)

expression1, expression2: Any numeric values or strings that you want to compare.

Comparison operators

= : Equal to

< : Less than

> : Greater than

<= : Less than or equal to

>= : Greater than or equal to

<> : Not equal to

Example:


Sub ExampleUnequal
Dim sFile As String
DIM sRoot As String ' Root directory for file in and output
    sRoot = "c:\"
    sFile = Dir$( sRoot ,22)
    If sFile <> "" Then
        Do
            MsgBox sFile
            sFile = Dir$
        Loop Until sFile = ""
    End If
End Sub

Please support us!