Beruflich Dokumente
Kultur Dokumente
Where object is the name of the control to add or delete from the control array. Index %
is the value of the index in the array. The control array to be added must be an element of
the existing array created at design time with an index value of 0. When a new element of
a control array is loaded, most of the property settings are copied from the lowest existing
element in the array.
* Open a Standard EXE project and save the Form as Calculator.frm and save the Project
as Calculater.vbp.
Prope
Object Setting
rty
Captio Calculator
n
Form
frmCalcul
Name ator
Captio
1
n
CommandBu
cmd
tton Name
0
Index
Captio
2
n
CommandBu
cmd
tton Name
1
Index
CommandBu Captio 3
tton n
cmd
Name
2
Index
Captio
4
n
CommandBu
cmd
tton Name
3
Index
Captio
5
n
CommandBu
cmd
tton Name
4
Index
Captio
6
n
CommandBu
cmd
tton Name
5
Index
Captio
7
n
CommandBu
cmd
tton Name
6
Index
Captio
8
n
CommandBu
cmd
tton Name
7
Index
Captio
9
n
CommandBu
cmd
tton Name
8
Index
CommandBu Captio 0
tton
n
cmd
Name
10
Index
Captio
.
n
CommandBu
cmd
tton Name
11
Index
Captio
AC
CommandBu n
tton
cmdAC
Name
Captio
+
CommandBu n
tton
cmdPlus
Name
Captio
-
CommandBu n
tton
cmdMinus
Name
Captio *
CommandBu n
tton cmdMultip
Name ly
Captio
/
CommandBu n
tton
cmdDivide
Name
Captio
+/-
CommandBu n
tton
cmdNeg
Name
Name txtDisplay
TextBox
Text ( empty )
CommandBu Captio =
tton n
cmdEqual
Name
The following code is entered in the cmd_Click( ) (Control Array) event procedure
The following code is entered in the click events of the cmdPlus, cmdMinus,
cmdMultiply, cmdDevide controls respectively.
Private Sub cmdDevide_Click()
txtDisplay.Text = ""
Previous = Current
Current = 0
Choice = "/"
End Sub
To print the result on the text box, the following code is entered in the cmdEqual_Click
( ) event procedure.
Case "+"
Result = Previous + Current
txtDisplay.Text = Result
Case "-"
Result = Previous - Current
txtDisplay.Text = Result
Case "*"
Result = Previous * Current
txtDisplay.Text = Result
Case "/"
Result = Previous / Current
txtDisplay.Text = Result
End Select
Current = Result
End Sub