Comparison Operators

Another class of operators commonly used in programming is the comparison operators, also known as relational operators in mathematics. These operators compare two values and return a Boolean value (True or False) depending on the result of the comparison. For example:

Dim i As Integer = 3, b As Boolean
b = i < 5

The expression i < 5 on the right side of the assignment operator = is a relational expression, and < is the comparison operator known as “less than.” It has the same meaning as its mathematical counterpart. The expression will be evaluated to True since i is 3 and therefore, is less than 5. The result of this evaluation (the Boolean value True) will then be assigned to the variable b. The Table 7.2 lists the comparison ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.