Beruflich Dokumente
Kultur Dokumente
CCP503.27 2
RECAP
Declaration of array
Properties of an array
CCP503.27 3
TYPES OF ARRAYS
Arrays are basically two types in the VB 6.0
1. Fixed size Arrays: which always remains the
same size
CCP503.27 4
FIXED SIZE ARRAYS
CCP503.27 5
Types of Arrays on the basis of nature
of data
Data to be stored in an array may be a single
group or in several groups.
Based on the nature of data, arrays may be
1. Single Dimensional Array: Only one dimension
Ex: Salaries of a set of employees ages of
students of a class
2. Multi Dimensional Array: means more than one
dimension.
Ex.: Salaries of employees of different departments
Names of students of different classes
CCP503.27 6
SINGLE DIMENSIONAL ARRAY
CCP503.27 8
CODE WINDOW
CCP503.27 9
STEPS - PROGRAM DESIGN AND CODING
Open a new Standard EXE project in design mode
For I = 0 To 9
Res = InputBox("Enter agesof student :”) Asks data and
stores in array
AgeList(I) = Res
For i=0 to 9
Next I Shows data on
Print age list (I)
screen with print
Next I statement
End Sub
CCP503.27 11
Save this program as .frmAgelist into your personal folder.
You will observe the input box will accept the Ages of 10
Students till the control lies in the For- Next loop
CCP503.27 12
Program to find the average salary of 10 employee and the
number of employees drawing salary higher than average
salary
STEPS :
Open a form
Put a command button on form and change its
name to “CmdAvg” and its caption to “More than
average salary”.
CCP503.27 13
Write the following code to click-event of
“Cmdavg”.
private Cmdavg-click ()
Dim salary (10) as long
Dim I as integer
Dim sum, Avg as long
Sum =0
Avg =0
For I =0 TO 9
Salary (I) =Input box (“give salary” ).
Sum = Sum + Salary (I)
Next I
Avg =sum/10
For I= 0TO 9
If salary (I) >Avg than print salary (I)
End if
Next I
End sub
CCP503.27 14
SUMMARY
Definition of an Array
Types of an Array
CCP503.27 15
FREQUENTLY ASKED QUESTIONS
CCP503.27 16
QUIZ
A. Data security
B. Information Security
C. Data Storage
D. Data binding
CCP503.27 17
2. Which is the property of an array?
A. Size
B. Subscript
C. Length
D. Elements
CCP503.27 18
3. An array can store any number of values
(True/False)
Ans: True
CCP503.27 19
Assignment
CCP503.27 20