Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21271

How to declare public array using a variable as the subscript in a BAS module?

$
0
0
Hi everyone!

It would be great if this worked!

Public TotalKeys as integer
Public Factors(TotalKeys) as double

I understand why this won't work:
The value of TotalKeys is not determined until after the public array Factors has been allocated sufficient memory, so there is no way of knowing how much memory to reserve.
So, what really needs to happen is a "Re-Dimensioning" of the array.
Don't know how to proceed.


Here's some of the original code:

Public Const TotalKeys = 12
Public Factors(TotalKeys) as double
Public KeyBin(TotalKeys) as integer

The root of the issue is this:
I have been tasked with changing an existing program to make the number of keys variable.
There over 100 Factor type declares using the TotalKeys constant.
I am looking for a straight forward - clean method to accomplish this without having to modify every single instance of the TotalKeys useage. The declares appear in several BAS modules.

Anyone have an idea?

Thanks!

Viewing all articles
Browse latest Browse all 21271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>