Sep 25, 2009

Operators in Visual Basic

An operator performs a function on one or more operands. For example, we add two variables with the "+" addition operator and store the result in a third variable with the "=" assignment operator. Visual Basic comes with many built-in operators that allow us to manipulate data.

Operators in VB.NET comes in different categories: (All in order of precedence)

Arithmetic Operators

Operator To Do
^ Exponentiation
- Negation (used to reverse the sign of the given value, exp -intValue)
* Multiplication
/ Division
\ Integer Division (Division without remainder 5\2= 2 and not 2.5)
Mod Modulus Arithmetic
+ Addition
- Subtraction

String Operators

Concatenation operators join multiple strings into a single string. There are two concatenation operators, + and &.

Comparison Operators

A comparison operator compares operands and returns a logical value based on whether the comparison is true or not. Please find them below.

= Equality Operator
<> Different or Not equal
< Less than
> Greater Than
<= Less Than or Equal
>= Greater than or equal

Last but not least Logical Operators

The logical operators compare Boolean expressions and return a Boolean result. Below a list of them.

And compare two Boolean expressions and return true if both of them are true else return false
Or compare two Boolean expressions and return false if both of them are false else return true
Not negate true to false and vice versa.

 

Happy VBNetting

No comments: