VB6 Constants

CoDeNcE

Gene Yuss?
Joined
21 Jul 2004
Messages
108
This is a n00bie question but me nor a friend can find the code to "create" a constant for a program im trying to do. The constant is to initalize an array to carry a name from one form to another form as a random names for brackets.
 
By definition a constant is a declared variable that does not change during the scope of execution, in other words an enigma. If you’re into arrays (I never use them, that is, declared arrays) then you could have a problem here as loading say fifty thousand elements into an array and then trying to coerce it to a static global value is not going to be easy or in fact possible.

It might be better turning the array problem on its head and declaring a function that programmatically inputs the values into a file (if they are this large) normally called a lookup table or if smaller values are in evidence (say a few hundred) then you can do this in VB by creating a string (using a specific format) but you need to be very careful here as string lengths for various data types need to be taken into account. However if it’s less than a hundred elements your probably better off declaring the constant with no definition and let VB coerce it to whatever value it thinks is most convenient. The downside of this approach is that your error checking must be spot on.

Large arrays can use huge amounts of memory and I find that their only real use outside of gaming code is to hold values less than fifty elements but creating the array in the first place normally requires a function to load in the values thus defeating the logic for using them, that is unless you are about to call hundreds of references to the array immediately after.

Another point worth considering is that if you have to declare a list of indexed values (array) as a constant in the first place then there is something basically wrong with the design of the code, or application you are designing. Do a Google search on “Dr Codd” for ideas about only storing things once and another about “Objects and Dependencies” although in the latter respect suggest that this may have cause the problem in the first place (re-usable code).

How many elements are you trying to coerce into a static value?


🙂 🙂 🙂
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie Electronic Punk Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. 🙁

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk Sazar Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,016
Messages
673,499
Members
5,630
Latest member
REALMTBENJOYER
Back