Certain types of arithmetic operations are performed a lot in most computer programs. These common arithmetic operations perform some arithmetic operation on the original value of a variable and then reassign the new value back to the original variable. A common example is the statement that increments a variable by 1, which is written as follows : Num = 10 ' Do some other stuff... Num = Num + 1 ' This increments Num by 1 In the last statement, you take the original value of The increment statement, Operand1 = Operand1 ArithmeticOperator Operand2 Because such operations are so common, Visual Basic .NET supplies shorthand operators to simplify these statements. With a shorthand operator, the increment statement can be rewritten as this: Num += 1 The effect on As you can see, the shorthand operator replaces this syntax: Operand1 = Operand1 ArithmeticOperator Operand2 with this: Operand1 ArithmeticOperator = Operand2 The only catch is that the arithmetic shorthand operators must do the assignment into themselves . Whereas ## Table 9.2. Shorthand Arithmetic Operators
The shorthand operators don't give you anything you didn't have before. They simply give you a shorter way to write the statements. (By the way, don't forget the shorthand operator for string concatenation, |

Visual Basic .NET Primer Plus

ISBN: 0672324857

EAN: 2147483647

EAN: 2147483647

Year: 2003

Pages: 238

Pages: 238

Authors: Jack Purdum

Similar book on Amazon

flylib.com © 2008-2017.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net