Code eg: Multiplication of two variables.
' Declare variables
Dim TotalDamage As Integer = 555
Dim TotalAgility As Integer = 6
' Create the expression
Dim TotalPoints As Integer = TotalDamage * TotalAgility
The expression in this example will evaluate to 3330.
Showing posts with label Arithmetic Operators. Show all posts
Showing posts with label Arithmetic Operators. Show all posts
Wednesday, October 27, 2010
Division
Code eg: Division of two integer variables
' Declare variables
Dim NumberOne As Integer = 9
Dim NumberTwo As Integer = 3
' Create the expression
Dim Result as Integer = NumberOne / NumberTwo
The expression in this example will evaluate to 3.
Subtraction
Code eg: Subtraction from two integer variables
' Declare variables
Dim TotalPointsPossible As Integer = 200
Dim TotalPlayerMisses As Integer = 50
' Create the expression
Dim TotalScore As Integer = TotalPointsPossible - TotalPlayerMisses
Dim TotalPlayerMisses As Integer = 50
' Create the expression
Dim TotalScore As Integer = TotalPointsPossible - TotalPlayerMisses
The expression in the example will evaluate to 150.
Addition
Code eg: Addition of two integer variables.
' Declare variables
Dim RoundOneScore As Integer = 5000
Dim RoundTwoScore As Integer = 4678
' Create the expression
Dim TotalScore As Integer = RoundOneScore + RoundTwoScore
Dim RoundTwoScore As Integer = 4678
' Create the expression
Dim TotalScore As Integer = RoundOneScore + RoundTwoScore
The expression in the example will evaluate to 9678
Arithmetic Operators
The following are arithmetic operators. They may be used in arithmetic expressions (maths problems)
- + Addition Operator
- - Subtraction Operator
- / Division Operator
- * Multiplication Operator
Subscribe to:
Posts (Atom)