• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

VB6 Constants

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 posts

Latest profile posts

Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member