VB.NET Operators | mod is operator in VB.NET | not operator in VB | visual basic logical operators | relational operators in VB | arithmetic operators in visual basic | arithmetic operators in VB | operators in VB.NET pdf | assignment operator in VB.NET
Table of Contents
VB.NET Operators
VB.NET provides various types of operators that allow you to manipulate data. Some examples of these operators are arithmetic, comparison, and logical.
Arithmetic Operators in VB.NET
Operator | Operation |
^ | Exponentiation |
* | Multiplication |
/ | Division |
\ | Integer Division |
Mod | Modulus |
+ | Addition |
– | Subtraction |
Assignment Operators in VB.NET
Operator | Operation |
= | Assignment |
^= | Exponentiation followed by assignment |
*= | Multiplication followed by assignment |
/= | Division followed by assignment |
\= | Integer Division followed by assignment |
+= | Addition followed by assignment |
-= | Subtraction followed by assignment |
&= | Concatenation followed by assignment |
Comparison Operators in VB.NET
Operator | Operation |
< | Less than |
<= | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |
= | Equal to |
<> | Not equal to |
Is | True if two object references refer to the same object |
Like | Perform string pattern matching |
String concatenation Operators in VB.NET
Operator | Operation |
& | String Concatenation |
+ | String Concatenation |
VB.NET Operators
VB.NET also supports logical/bitwise operators. Where bitwise means working bit by bit with numerical values. These types of operators work on logical values or numbers for bitwise operations, which work on their operands bit by bit.
Logical and Bitwise Operators in VB.NET
- Operator: And
- Description: Performs an And operation (for logical operations: True if both operands are True. False otherwise; the same for bit-by-bit operations where you treat 0 as false and 1 as true)
- Operator: Not
- Description: Reverses the logical value of its operand. from true to false and false to true. For bitwise operations, turns 0 into 1 and 1 into 0
- Operator: Or
- Description: Performs an Or operation (for logical operations: True if either operand is True. False otherwise; the same for bit-by-bit operations where you treat 0 as false and 1 as true.)
- Operator: Xor
- Description: Compute the logical exclusive-OR of its Boolean operands. It returns true if only one of its operands is true.
- Operator: AndAlso
- Description: Perform the logical operation to Boolean operands. If the first operand is false, the second operand is not tested.
- Operator: OrElse
- Description: Perform the logical operation to Boolean operands. If the first operand is true, the second operand is not tested.
Miscellaneous Operators in VB.NET
Operator | Description |
AddressOf | Gets the address of a procedure |
GetType | Gets information about a type |
TypeOf | Compares an object reference variable to a data type |
The following code snippet shows the addition of two numbers:
Dim num1 as Integer = 12
Dim num2 as Integer = 23
Dim num3 as Integer
num3=num1+num2
The preceding code snippet prints the result of adding 12 and 23, which is 35. An operator works on operands. For example, in the expression 5 + 4, 5 is the first operand, + is the operator, and 4 is the second operand.
Also Read:
Hope it can be helpful. VB.NET Operators
And don’t forget to share with your friends and family this post.