Modifying numerical data
In VB, you can modify numerical data using many different operators and functions. We will focus on three types of numerical operations: mathematical, rounding/truncation, and type conversions.
Mathematical operations
The traditional math operations are supported in VB:
- Addition: You can add numeric values using the
+
operator. Here is an example:Dim n1 As Integer = 4 Dim n2 As Integer = 2 Dim n3 As Integer = n1 + n2
The preceding code will declare two integer variables (
n1
andn2
) and add them together, storing their result in the third variable namedn3
. - Subtraction: You can subtract values using the
-
operator. Here is an example:Dim n1 As Integer = 4 Dim n2 As Integer = 2 Dim n3 As Integer = n1 - n2
The preceding code will declare two integer variables (
n1
andn2
) and subtractn2
fromn1
, storing the result in the third variable namedn3
. - Multiplication: You can multiply values using the
*
operator. Here is an example:Dim n1 As Integer...