Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

collection of user constants?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bismuth - 20 Dec 2004 23:39 GMT
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!


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.