Changes

Visual Basic Arithmetic

1 byte removed, 19:30, 13 August 2007
no edit summary
</pre>
In the above expression, the ''intResult < 20'' expression will retunr return either ''True'' or ''False'' depending on whether the value held by the ''intResult'' variable is less than 20 or not.
Expressions can be made up of multiple operands and expressions:
== Visual Basic Operator Precedence ==
In an earlier example we looked an expression which contained a variety of different operators. Anotehr Another example is as follows:
<pre>
</pre>
The issue we have to address now is in what order these calculations will be performed. If Visual Basic were to evaluate the expression from left to right the result would be 180. If the expression is evaluated from right to left the result would be 104. So, which way does Visual Basic evaluation expressions? The answer is neither of these options. Instead, Visual Basic evaluates expressions according to operator precendeceprecedence. This is essentially a predefined order in which expressions are calculated which matches the standard algebraic order. The order used by Visual Basic is as follows:
<table border="1" cellspacing="0">
Given this order of precedence, our example will evaluate in the order of multiplication followed by addition resulting in a value of 104.
Now that we understand what ''epxressionsexpressions'' are and the order of operator precedence we can move onto look at operators in action.
== Visual Basic Addition ==
== Visual Basic Subtraction and Negation ==
The subtraction (-) is used to perfrom perform subtraction in Visual Basic:
<pre>
== Visual Basic Exponentiation ==
Exponentiataion Exponentiation involves raising a number to a particular power. For example 10<sup>3</sup> which would evaluate to 1000. The carat (^) character is used to represent exponentiation in Visual Basic:
<pre>