Compare in Visual Basic .NET

Find this useful? Support us: Star on GitHub 6
Category: String | Language: Visual Basic .NET

In Visual Basic .NET, you can compare numbers using the following operators:

1. Greater than: >
2. Less than: <
3. Greater than or equal to: >=
4. Less than or equal to: <=
5. Equal to: =
6. Not equal to: <>

Here are examples of how they can be used:

Dim x As Integer = 10
Dim y As Integer = 5

Console.WriteLine(x > y) 'output: True
Console.WriteLine(x < y) 'output: False
Console.WriteLine(x >= y) 'output: True
Console.WriteLine(x <= y) 'output: False
Console.WriteLine(x = y) 'output: False
Console.WriteLine(x <> y) 'output: True

In this example, we have defined two variables, x and y, and assigned them values of 10 and 5 respectively.

Using the Console.WriteLine statement and the operators explained above, we are able to compare the values of x and y and return logical results.

The output indicates whether each comparison is true or false.