collection of user constants?

B

bismuth

Does VB/A create a collection of user-defined constants for you?

If you had inside modEmployees:
public const NAME_1 as string = "Dan"
public const NAME_2 as string = "Bill"

You could refer to them with:
for iIndex = 1 to 2
debug.print modEmployees.Constants("NAME_" & iIndex)
next iIndex

I'm thinking this isn't an automatic thing, but it couldn't hurt to
ask.

Thanks for the help --
 
J

Jezebel

No. Once the app is compiled the names aren't there at all, only pointers.
But in any case, this is missing the point. Constants are a shorthand for
literals. If you have a number of items and you need to iterate them, then
you shouldn't be using constants at all. And you sure as hell don't want to
hard-code employee names into an application ... apart from anything else,
you'll jinx their employment :)
 
J

Jeff Johnson [MVP: VB]

Does VB/A create a collection of user-defined constants for you?

No. To put it simply (and a bit abstractly), constants are for design-time,
not run-time.
 
B

Brian Schwartz

public const NAME_1 as string = "Dan"
public const NAME_2 as string = "Bill"

You could refer to them with:
for iIndex = 1 to 2
debug.print modEmployees.Constants("NAME_" & iIndex)
next iIndex


What you're doing looks more like a job for an array.
 

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