Visual Basic includes a variety of operators that let you manipulate the values of your variables. You've already seen the assignment operator (
=), which lets you assign a value directly to a variable. Most of the other operators let you build up expressions that combine multiple original values in formulaic ways for eventual assignment to a variable. Consider the following statement:
squareArea = length * width
This statement includes two operators: assignment and multiplication. The multiplication operator combines two values (
width) using multiplication, and the assignment operator stores the product in the
squareArea variable. Without operators, you would be hard-pressed to calculate an area or any complex formula.
There are two types of non-assignment operators: unary and binary. Unary operators work with only a single value, or operand. Binary operators require two operands, but result in a single processed value. Operands include literals, constants, variables, and function return values. Table 6-7 lists the different operators with usage details.
Table 6-7. Visual Basic non-assignment operators
Addition. Adds two operands together, producing a sum. Some programmers also use this operator to perform string concatenation, but it's better to join strings using another operator (
Unary plus. Ensures that an operand retains its current sign, either positive ...