Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to Initialize arrays at declaration time

Posted on 2003-02-22
5
Medium Priority
?
155 Views
Last Modified: 2010-04-07
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.
0
Comment
Question by:jnhgustin
  • 3
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7999613
Dim Mytypes() as MYTYPE


you can do this whereever:

ReDim MyTypes(10)
0
 

Author Comment

by:jnhgustin
ID: 7999631
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.



 
0
 
LVL 3

Accepted Solution

by:
Gunsen earned 100 total points
ID: 7999659
Not possible with VB 6, but in VB.net
Use for load to initialize array

Dim arr
arr = Split( "a","b","c")
0
 

Author Comment

by:jnhgustin
ID: 7999857
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.



 
0
 

Author Comment

by:jnhgustin
ID: 8001151
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.



 
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question