An operator tells ASP.NET what kind of command to perform in an expression.
The VB language supports many operators. Below is a list of common operators:
| Operator | Description | Example |
|---|---|---|
| = | Assigns a value to a variable. | i=6 |
| + - * / |
Adds a value or variable. Subtracts a value or variable. Multiplies a value or variable. Divides a value or variable. |
i=5+5 i=5-5 i=5*5 i=5/5 |
| += -= |
Increments a variable. Decrements a variable. |
i += 1 i -= 1 |
| = | Equality. Returns true if values are equal. | if i=10 |
| <> | Inequality. Returns true if values are not equal. | if <>10 |
| < > <= >= |
Less than. Greater than. Less than or equal. Greater than or equal. |
if i<10 if i>10 if i<=10 if i>=10 |
| & | Adding strings (concatenation). | "w3" & "schools" |
| . | Dot. Separate objects and methods. | DateTime.Hour |
| () | Parenthesis. Groups values. | (i+5) |
| () | Parenthesis. Passes parameters. | x=Add(i,5) |
| () | Parenthesis. Accesses values in arrays or collections. | name(3) |
| Not | Not. Reverses true or false. | if Not ready |
| And OR |
Logical AND. Logical OR. |
if ready And clear if ready Or clear |
| AndAlso orElse |
Extended Logical AND. Extended Logical OR. |
if ready AndAlso clear if ready OrElse clear |
Practice Excercise Practice now