Link to home
Start Free TrialLog in
Avatar of jnhgustin
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.
Avatar of bobbit31
bobbit31
Flag of United States of America image

Dim Mytypes() as MYTYPE


you can do this whereever:

ReDim MyTypes(10)
Avatar of jnhgustin
jnhgustin

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.



 
ASKER CERTIFIED SOLUTION
Avatar of Gunsen
Gunsen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.



 
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.