# Visual Basic Operators

In Visual Basic, Operator is a programming element that specifies what operation needs to perform on operands or variables. For example, an addition (+) operator in Visual Basic is used to perform the sum operation on operands.

## Visual Basic Operator Types

In Visual Basic different types of operators are available; those are

Now, we will learn each operator in a detailed manner with examples in the Visual Basic programming language.

## Visual Basic Arithmetic Operators

In Visual Basic, Arithmetic Operators are useful for performing basic arithmetic calculations like addition, subtraction, division, etc., based on our requirements.

The following table lists the different arithmetic operators available in Visual Basic.

OperatorDescriptionExample (a = 6, b = 3)
+ It will add two operands. a + b = 9
- It will subtract two operands. a - b = 3
* It will multiply two operands. a * b = 18
/ It divides two numbers and returns a floating-point result. a / b = 2
\ It divides two numbers and returns an integer result. a \ b = 2
Mod It divides two numbers and returns only the remainder. a Mod b = 0
^ It raises a number to the power of another number. a ^ b = 216

## Visual Basic Assignment Operators

In Visual Basic, Assignment Operators are useful to assign a new value to the operand.

The following table lists the different assignment operators available in Visual Basic.

OperatorDescriptionExample
= It will assign a value to a variable or property. a = 10
+= It will add left and right operands and assign a result to the left operand. a += 10 equals to a = a + 10
-= It will subtract left and right operands and assign a result to the left operand. a -= 10 equals to a = a - 10
*= It will multiply left and right operands and assign a result to the left operand. a *= 10 equals to a = a * 10
/= It will divide left and right operands and assign the floating-point result to the left operand. a /= 10 equals to a = a / 10
\= It will divide left and right operands and assign the integer result to the left operand. a \= 10 equals to a = a \ 10
^= It will raise the value of a variable to the power of expression and assign the result back to the variable. a ^= 10 equals to a = a ^ 10
&= It will concatenate a String expression to a String variable and assign the result to the variable. a &= "World" equals to a = a & "World"
>>= It will move the left operand bit values to the right based on the number of positions specified by the second operand. a >>= 2 equals to a = a >> 2
<<= It will move the left operand bit values to the left based on the number of positions specified by the second operand. a <<= 2 equals to a = a << 2

## Visual Basic Logical / Bitwise Operators

In Visual Basic, Logical / Bitwise Operators are useful to perform the logical operation between two operands like AND, OR, etc., based on our requirements. The Logical / Bitwise Operators will always work with Boolean expressions (true or false) and return Boolean values.

The following table lists the different types of logical/bitwise operators available in Visual Basic.

OperatorDescriptionExample (a = True, b = False)
And It will return true if both operands are non zero. a And b = False
Or It will return true if any one operand becomes a non zero. a Or b = True
Not It will return the reverse of a logical state that means if both operands are non zero, it will return false. Not(a And b) = True
Xor It will return true if any one of expression1 and expression2 evaluates to true. a Xor b = True
AndAlso It will perform the short-circuiting logical operation and return true if both operands evaluate to true. a AndAlso b = False
OrElse It will perform the short-circuiting logical operation and return true if any operand evaluates to true. a OrElse b = True
IsFalse It will determine whether an expression is False.
IsTrue It will determine whether an expression is True.

## Visual Basic Comparison Operators

In Visual Basic, Comparison Operators are useful to determine whether the defined two operands are equal, greater than or less than, etc., based on our requirements.

The following table lists the different comparison operators available in Visual Basic.

OperatorDescriptionExample (a = 10, b = 5)
< It will return true if the right operand is greater than the left operand. a < b = False
<= It will return true if the right operand is greater than or equal to the left operand. a <= b = False
> It will return true if the left operand is greater than the right operand. a > b = True
>= It will return true if the left operand is greater than or equal to the right operand. a >= b = True
= It will return true if both operands are equal. a = b = False
<> It will return true if both operands are not equal. a <> b = True
Is It will return true if two object references refer to the same object.
IsNot It will return true if two object references refer to different objects.

## Visual Basic Concatenation Operators

In Visual Basic, Concatenation Operators are useful to concatenate defined operands based on our requirements.

The following table lists the different types of concatenation operators available in Visual Basic.

OperatorDescriptionExample (a = Hello, b = World)
& It will concatenate given two expressions. a & b = HelloWorld
+ It is useful to add two numbers or concatenate two string expressions. a + b = HelloWorld