Array Declarations


VB 6.0


Typical array declarations

        Dim intValue (9) As Integer

       

'Index values are 0-9

        Dim intValue (1 To 10) as Integer

       

'Index values are 1-10

        Dim intValue (4, 4) as Integer

       

'A two-dimensional array

        Dim intValue (1 To 5, 1 To 5) as Integer

       

'Another two-dimensional array

Code that puts 10 interest rates into a one=dimensional array

Dim cRate (1 To 10) As Single

cRate(1) = .01

cRate(2) = .02

cRate(3) = .03

cRate(4) = .04

cRate(5) = .05

cRate(6) = .06

cRate(7) = .07

cRate(8) = .08

cRate(9) = .09

cRate(10) = .10


Code that puts 10 interest rates into a two-dimensional array

Dim cRate (1, 4) As Single

cRate(0, 0) = .04

cRate(0, 1) = .05

cRate(0, 2) = .06

cRate(0, 3) = .07

cRate(0, 4) = .08

cRate(1, 0) = .045

cRate(1, 1) = .055

cRate(1, 2) = .065

cRate(1, 3) = .075

cRate(1, 4) = .085



Description



A For...Next statement that puts the numbers 1 through 10 in an array


Dim iIndex As integer, iArray (1 To 10 As Integer
For iIndex = 1 To 10

    iArray (iIndex) = iIndex

Next iIndex




A For...Next statement that puts the numbers 2, 4, 6, 8, and 10 into array items 2, 4, 6, 8, and 10


Dim iIndex As Interger, iArray (1 To 10) As Integer

For iIndex = 2 To 10 Step 2

    iArray (iIndex) = iIndex

Next iIndex






VB PAGE

HOME


Last update:   7-14-2003 at 2:00pm