Comparison operators are used to compare sizes, the result is "True" or "False", and if the operand contains "Empty", it is treated as "0".
Common comparison operators are shown in the following table:
| Operator |
Name |
Type |
Description |
| < |
Less than |
Binocular operator |
The operand can be any reasonable expression |
| <= |
Less than or equal to |
Binocular operator |
Same less than number |
| > |
Greater than |
Binocular operator |
Same less than number |
| >= |
Greater than or equal to |
Binocular operator |
Same less than number |
| = |
Equals |
Binocular operator |
Same less than number |
| <> |
Not equal to |
Binocular operator |
Same less than number |
In addition, vb.net has two comparison operators: "is" and "like".
1.Is operator
The operator of the IS operator requires an "object" type and returns "true" if the two operands represent the same object, and vice versa, for example:
Dim Myobject,yourobject,thisobject,otherobject,thatobject as Object
Dim MyCheck as Boolean
Yourobject=myobject
Thisobject=myobject
Thatobject=otherobject
Mycheck=yourobject is Thisobject ' returns true
Mycheck=thatobject is Thisobject ' returns false
Mycheck=myobject is Thisobject ' returns false
2.Like operator
The first operand of like is a "string" type, and the second operand requires a standard style of "string" or string. The standard style of a string consists primarily of 5 points:
(1). "?" Represents a single character
(2). " * "represents 0 or more characters
(3). " # "represents a single digit of 0-9
(4). [Character list] represents any character in the list
(5). [! Character list] represents any character that is not in the list
The following example illustrates the use of "like":
Dim MyCheck as String
mycheck= "Abbba" like "A*a" returns True
mycheck= "F" like "[A-Z]" ' Returns true
mycheck= "F" like "[!] A-z] "' returns false
mycheck= "A2A" like "a#a" returns True
mycheck= "am5b" like "A[L-P]#[!C-E]" returns True
mycheck= "BAT123KHG" like "B"? T* "' Returns True
mycheck= "CAT123KHG" like "B"? T* "' Returns True