jnhgustin
asked on
How to Initialize arrays at declaration time
Hi. Hopefully this is a simple question. I simply want to declare an array of structures and fill it with constant values.
For example:
Public Type MYTYPE
myint as integer
mystr as string
end type
Public MyTypes(10) as MYTYPE
I know I could assign the values in a routine here, but is there some way I can just assign them at declaration time. I know I can do it in C, what about VB?
Any help is appreciated?
Thanks.
For example:
Public Type MYTYPE
myint as integer
mystr as string
end type
Public MyTypes(10) as MYTYPE
I know I could assign the values in a routine here, but is there some way I can just assign them at declaration time. I know I can do it in C, what about VB?
Any help is appreciated?
Thanks.
ASKER
I new I wasn't being clear, that's why I'm having trouble. The answer I'm hoping for is something like:
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I new I wasn't being clear, that's why I'm having trouble. The answer I'm hoping for is something like:
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
ASKER
I new I wasn't being clear, that's why I'm having trouble. The answer I'm hoping for is something like:
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
Public MyTypes(10) as MYTYPE = { 1, "x", 2, "y", ... }
or something like that I would hope. The key is initializing the values or setting them as constants.
you can do this whereever:
ReDim MyTypes(10)