# Operators

An
*operator* is a symbol (e.g.,
`=`

, `+`

, `>`

,
`&`

) that causes VB.NET to take an action. That
action might be an assignment of a value to a variable, the addition
of two values, a comparison of two values, concatenation of strings,
etc.

In the previous sections, you’ve seen a number of
operators at work. For example, the
assignment operator (`=`

)
has been used to assign a value to a variable:

Dim myVariable As Integer myVariable = 15

In the code shown above, the value 15 is assigned to the Integer
variable myVariable. In the section on branching you saw more
sophisticated operators, such as the greater-than
comparison operator
(`>`

) used to compare two values:

If valueOne > valueTwo Then

The preceding `If`

statement compares valueOne with
valueTwo; if the former is larger than the latter, the test evaluates
true, and the `If`

statement executes.

The following sections will consider many of the operators used in VB.NET in some detail.

## Mathematical Operators

VB.NET
uses seven mathematical operators: five for standard calculations
(`+`

, `-`

, `*`

,
`/`

, and `\`

), a sixth to return
the remainder when dividing integers (`Mod`

), and a
seventh for exponential operations (`^`

). The
following sections consider the use of these operators.

### Simple arithmetic operators (+, -, *, /, \)

VB.NET offers five operators for
simple arithmetic: the
addition (`+`

),
subtraction (`-`

), and multiplication
(`*`

) operators work as you might expect. Adding two numbers returns their sum, subtracting returns their difference, and ...

Get *Programming Visual Basic .NET, Second Edition* now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.