Professional Documents
Culture Documents
CCP503
CCP503
CCP503.30 2
RECAP
Types of arrays,
Multi-dimensional arrays
CCP503.30 3
Program1 on Arrays
Write a program to accept a list of 10
numbers and compute its sum, print
them on to the form with its sum.
CCP503.30 4
Follow the steps to develop an application
On array:
CCP503.30 5
Private sub CmdDo_Click()
Dim I as Integer
Dim Arr(10) as Integer
Dim s AS Long
For I = 0 to 9
Arr(I) = InputBox(“enter a number “)
Next I
For I = 0 to 9
S = S + Arr (I)
print Arr(I)
Next I
End sub
CCP503.30 6
Program2 on Arrays to accept a list of
numbers, and sort them in an
ascending order using Bubble Sort
Technique.
CCP503.30 7
Program to sort a set of value
Create a form and paste a command button with name cmdsort
Write the following code to the command button and run the program and see
Private sub Cmdsort_click ()
Dim m (5) as integer
Dim I as Integer, J as Integer
Dim d as Integer
for I = 0 to 4
m (I) = Inputbox (“Give a no:”)
next I
for I = 0 to 3
for J = I + 1 to 4
If m (I) > m (J) Then
d = m (I)
m (I) = m (J)
m (J) = d
End if
Next J
Next I
for I = 0 to 4
PRINT m (I)
Next I
End sub
CCP503.30 8
Summary
In this Session, you have learnt about
writing sample programs on Arrays in VB
CCP503.30 9
Frequently Asked Questions
CCP503.30 10
QUIZ
1 Dim I as Integer
Dim Arr[10] as Integer
For I = 1 to 10
Arr = input box (“give a no;”)
Next I
In which line is there an error
A. 2
B. 4
C. 5
D. 7
CCP503.30 11
2. Find the error from the following
code, in which line it is?
For i=0 to 2
For j=0 to 2
print “ GTPSKLM”
next I
next I
F. First line
G. Second Line
H. Third line
I. Fourth line
J. Fifth line
CCP503.30 12
Assignment
CCP503.30 13