Page 128 - Open Soource Technologies 304.indd
P. 128
Event Driven Programming
Since Visual Basic does not provide for array of masked text boxes, we will
only use ordinary text boxes for input.
Control array are created in much the same way as any other array; that is, with a statement
of the form
Dim arrayName(n) As ControlType
or
Dim arrayName() As ControlType
For instance, the following statements declare control array.
Dim lblTitle(10) As Label
Dim txtNumber(8) As TextBox
Dim btnAmount() As Button
1: A department store has five departments. The following program requests
the amount of sales for each department and displays the total sales for the
store. The five labels identifying the departments are grouped into an array
of labels and the five text boxes for the individual amounts are grouped into
an array of text boxes. The initial settings for these labels are specified at
run time in the frmSales_Load event procedure instead of being specified
at design time. The Text properties of the labels are set to be “Department
1”, “Department 2”, and so on.
Object Property Setting
frmSales Text Daily Sales:
Label1Label5 TextBox1TextBox5 btnCompute Text Compute Total Sales
lblTotal Text Total Sales
txtTotal ReadOnly True
Dim lblDept(4) As Label
DimtxtDept(4)As TextBox
122 LOVELY PROFESSIONAL UNIVERSITY