In order to create new information from the original values, literal and variables data values are involved in processing operations.
A D V E R T I S E M E N T
The two most common ways to manipulate variables and constants are through arithmetic and string operations.
To contruct these processing statements, or expressions, visual Basic supplies arithmetic and string operators.
Arithmetic Operators
Much of information processing involves applying arithmetic to numeric data types and values are added, subtracted, multiplied, and divided to generate results, either final results or intermediate values that are involved in further arithmetic operations. For these purposes Visual Basic supplies a set of seven arithmetic operators shown in the following table.
Operator
Use
+
Addition. Adds the values appearing on the two sides of the
operator.
-
Subtraction. Subtracts the value on the right of the operator from
the value on the left of the operator.
*
Multiplication. Multiplies the values appearing on the two sides of
the operator.
/
Division. Divides the value on the left of the operator (dividend)
by the value on the right of the operator (divisor).
\
Integer Division. Divides the value on the left of the operator by
the value on the right of the operator, giving an Integer result.
Mod
Modulo Division. Returns the remainder of the division of the
value on the left of the operator by the value on the right of the
operator.
^
Exponentiation. Raises the value on the left of the operator to the
power on the right of the operator.
Example
Dim Answer1, Answer2 As Single
Answer1 = 1 + (2 / 3)
Answer2 = (1 + 2) / 3)
String Operators
Visual Basic supplies the concatenation operator (&) to put together individual data strings to create a longer string of those combinations and the Like operator looks for matching characters in a string.
Operator
Use
& or +
Concatenation. Appends the string value appearing on the right of
the operator to the string value on the left of the operator.
Like
Determines whether a string matches a given pattern.