VB.nET Operators Explained in Fewer than 500 Words

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

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.

String concatenation Operators in VB.NET

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

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.