Beruflich Dokumente
Kultur Dokumente
NDHRA PRADESH
CCP-503.10 2
Objectives :
Upon the completion of this period the student
will be able to
CCP-503.10 3
Control Array
CCP-503.10 5
Adding a Control Array at Run Time
CCP-503.10 6
Control Array application
This application uses a set of Command Button
Controls in an array to illustrate the working
of a Calculator.
A standard EXE Form is created and saved
The Form is designed as per the following
specifications
Note: This application may be explained after
covering the programming part
CCP-503.10 7
Control Array application (Calculator)
CCP-503.10 9
Control Array application (Calculator)
CCP-503.10 11
Control Array application (Calculator)
In addition to these Controls, six more
Command Button controls are added with the
following specifications.
Object Property Settings
Command Button Name CmdPlus
Caption +
Command Button Name CmdMinus
Caption -
Command Button Name CmdDiv
Caption /
CCP-503.10 12
Control Array application (Calculator)
CCP-503.10 13
Control Array application (Calculator)
CCP-503.10 14
Control Array application (Calculator)
CCP-503.10 15
Control Array application (Calculator)
CCP-503.10 16
Control Array application (Calculator)
CCP-503.10 17
Control Array application (Calculator)
CCP-503.10 18
Control Array application (Calculator)
Enter the following code in the Click event of
the CmdPlus, CmdMinus, CmdMul, CmdDiv
controls respectively.
CCP-503.10 19
Control Array application (Calculator)
CCP-503.10 20
Control Array application (Calculator)
CCP-503.10 21
Control Array application (Calculator)
CCP-503.10 22
Control Array application (Calculator)
Enter the following code in the
CmdEqual_Click() event to print the result in
the Text Box
Private Sub CmdEqual_Click()
Select Case Choice
Case "+"
Result = Preval + Curval
Text1.Text = Str(Result)
Case "-"
Result = Preval - Curval
Text1.Text = Str(Result)
CCP-503.10 23
Control Array application (Calculator)
Case "*"
Result = Preval * Curval
Text1.Text = Str(Result)
Case "/"
Result = Preval / Curval
Text1.Text = Str(Result)
End Select
Curval = Result
End Sub
CCP-503.10 24
Control Array application (Calculator)
CCP-503.10 25
Control Array application (Calculator)
CCP-503.10 26
Control Array application (Calculator)
CCP-503.10 27
Control Array application (Calculator)
CCP-503.10 28
Control Array application (Calculator)
CCP-503.10 29
Summary
The Control Arrays in Visual Basic
CCP-503.10 30
Quiz
1. Control Arrays are added at run time
using _______
A) Load Object
B) Store Object
C) Run Object
D) UnLoad Object
CCP-503.10 31
2. Which property is NOT same for all the
Controls of Control Array ?
A) Caption
B) Name
C) Font
D) Index
CCP-503.10 32
Frequently Asked Questions
CCP-503.10 33
Assignment
1. Create a Control array based application
CCP-503.10 34