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 --
Jezebel - 20 Dec 2004 23:49 GMT
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 :)
> Does VB/A create a collection of user-defined constants for you?
>
[quoted text clipped - 11 lines]
>
> Thanks for the help --
Jeff Johnson [MVP: VB] - 21 Dec 2004 00:51 GMT
> 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.
Brian Schwartz - 23 Dec 2004 16:20 GMT
> public const NAME_1 as string = "Dan"
> public const NAME_2 as string = "Bill"
[quoted text clipped - 3 lines]
> debug.print modEmployees.Constants("NAME_" & iIndex)
> next iIndex
What you're doing looks more like a job for an array.

Signature
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Building better tools for developers - Be part of it!