comparison operator for vb.net

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.