Visual Basic 6 programming: Learn programming with Visual Basic 6 by Unknown
Table 6.1: Arithmetic Operators
Operator
Mathematical function
Example
^
Exponential
2^4=16
*
Multiplication
4*3=12,
/
Division
12/4=3
Mod
Modulus (returns the remainder from an integer division)
15 Mod 4=3
\
Integer Division(discards the decimal places)
19\4=4
+ or &
String concatenation
"Visual"&"Basic"="Visual Basic"
Example 6.1
Private Sub Command1_ Click()
Dim firstName As String
Dim secondName As String
Dim yourName As String
firstName = Text1.Text
secondName = Text2.Text
yourName = secondName + " " + firstName
Label1.Caption = yourName
End Sub
In this example, three variables are declared as string. For variables firstName and secondName will receive their data from the user’s input into textbox1 and textbox2, and the variable yourName will be assigned the data by combining the first two variables. Finally, yourName is displayed on Label1.