Export (0) Print
Expand All

Operators

An operator is a code unit that performs an operation on one or more value-returning code elements. Such an operation can be an arithmetic operation such as addition or multiplication; a concatenation operation that combines two strings into a new string; a comparison operation that determines which of two values is greater; a logical operation evaluating whether two expressions are both true. Operators combined with value-returning code elements such as literals or variables form expressions, or in the case of the assignment operator, statements.

The following is an example of a statement that uses the simple assignment operator (=):

x = 45

In the preceding example, the assignment operator performs the assignment operation: it takes the value on the right side of the operator and assigns it to the variable on the left. Several operators can perform actions in a single expression or statement, as demonstrated below:

x = 45 + y * z ^ 2

In this example, the operations in the expression on the right side of the assignment operator are performed, and the resulting value is assigned to the variable x, on the left. There is no limit to the number of operators that can be combined into an expression, but an understanding of Operator Precedence in Visual Basic is necessary to ensure that you get the results you expect. For more information, see Efficient Combination of Operators.

In This Section

Arithmetic Operators
Discusses operators used to perform many familiar arithmetic operations that involve calculation of numeric values represented by literals, variables, other expressions, function and property calls, and constants.
Comparison Operators
Discusses operators that compare two expressions and return a Boolean value representing the result of the comparison.
Concatenation Operators
Provides information on the + and & operators, which join multiple strings into a single string.
Logical Operators
Provides information on operators that compare Boolean expressions and return a Boolean result.
Efficient Combination of Operators
Discusses how to create complex numeric, Boolean, and parenthetical expressions, assuming knowledge of operator precedence.

Related Sections

Expressions
Shows how to combine elements with operators to yield new values.
Statements
Provides an overview of the two basic units of instruction in Visual Basic: declaration statements and executable statements.
Operators
Provides links to Language Reference topics covering all Visual Basic operators, listed by category.
Show:
© 2014 Microsoft