Can you store a value in different levels of a multi array?

G

Gerardo

I'm working with arrays, and I thought that I could store the names for
(let's say) rows in level one of the array, and then have stored values in
the second level. But it seems that the only place to store values is the
last level of the array. Does that means that I have to keep a second array
with the names for first level elements?

Moreover, if I need "redim preserve" it looks that I can't add a second
dimension to one dimensional array.
 
M

merjet

Consider a user-defined data type. An example follows.

'declarations
Type Customer
Name as String
Purchase() As Single
End Type

Sub Main()

Dim tCust(1 to 2) As Customer
tCust(1).Name = "Bill"
ReDim tCust(1).Purchases(1 to 2)
tCust(1).Purchase(1) = 20.25
tCust(1).Purchase(2) = 29.00

End Sub

Hth,
Merjet
 
A

Alan Beban

Gerardo said:
I'm working with arrays, and I thought that I could store the names for
(let's say) rows in level one of the array, and then have stored values in
the second level. But it seems that the only place to store values is the
last level of the array. Does that means that I have to keep a second array
with the names for first level elements?
Not clear what you mean by "the only place to store values is the last
level of the array"?
Moreover, if I need "redim preserve" it looks that I can't add a second
dimension to one dimensional array.

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

arr = TwoD(arr)

Alan Beban
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top