Professional Documents
Culture Documents
Ú
Ú Õome arrays have two dimensions, such as the number of
offices on each floor of each building on a campus.
Ú The specification of an element requires both the building
number and the floor, and each element holds the count for
that combination of building and floor.
Ú
m
{ 40 buildings and 5 floors in each building! }
ÚÕuppose we want to store total marks of 50
students of one class, we can use 1-D array as ::
Dim tot_marks(50) as double
! ""
""
Ú Lets discuss an application which assigns values
to 1-D array and prints its values to a list box «
Dim newarray(10) As Integer
d
uor i = 0 To 9
newarray(i) = i + 1
Next i
MsgBox "values assigned successfully to NEWARRAi",
vbInformation, "result"
d
uor i = 0 To 9
list1.AddItem (newarray(i))
Next i
Ú Õ RTING u 1-D ARRAi «.
Dim newarray(10) As Integer
Dim n As Integer
Dim i, j, temp As Integer
d
n = list1.ListCount
#
$
%
&
$
'()
* +
#
$
%
#
,
$
-
%
.
&
/
& ,
!
$
&
&
$
& ,
& ,
$
!
.
* +
,
* +
.
#
$
%
&
)()
$
&
* +
Ú MATRIX ERATI NÕ..
ADD
ÕBTRACT
MLTILi
0
.
.
d
#
)
count1 = 0
count2 = 4
uor i = 0 To 1
uor j = 0 To 1
mat1(i, j) = count1
mat2(i, j) = count2
count1 = count1 + 1
count2 = count2 - 1
Next j
Next i
uor i = 0 To 1
uor j = 0 To 1
List1.AddItem mat1(i, j)
List2.AddItem mat2(i, j)
Next j
Next I
rivate Õub Command1_Click()
uor i = 0 To 1
uor j = 0 To 1
mat3(i, j) = mat1(i, j) + mat2(i, j)
List3.AddItem mat3(i, j)
Next j
Next i
End Õub
rivate Õub Command3_Click()
uor i = 0 To 1
uor j = 0 To 1
mat3(i, j) = mat1(i, j) - mat2(i, j)
List3.AddItem mat3(i, j)
Next j
Next i
End Õub
d
uor i = 0 To 1
uor j = 0 To 1
mat3(i, j) = 0
uor k = 0 To 1
mat3(i, j) = mat3(i, j) + (mat1(i, k) * mat2(k, j))
Next k
List3.AddItem mat3(i, j)
Next j
Next i
G D DAi !!