Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are global arrays possible???

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Thanks to you lot, I have managed to get all my data out of my database and into arrays (Thankyou MikeCox!), but i need to pass these arrays to another form to use them in a graph. How can i do this, as when i try to make the arrays global variables, VB6 doesn't let me...
 
The only place where global arrays aren't allowed is inside class modules (which is a major inconvenience for C++ programmers). If you aren't trying to put them in a class, you may need to tell VB how big the arrays are going to be:

Public MyArray(0 to 100) as String

However, this requires you to know ahead of time how big the array is going to be. Since you don't know this, use this syntax:

Public MyArray() as String

Now you can change the array's size at run-time just before that loop I showed you earlier:

ReDim MyArray(0 to Adodc1.Recordset.RecordCount -1) as String

Try that, and let me know if it doesn't work. I've ticked the E-Mail me notification, so just respond to this post.

-Mike
 
Thanks again, but one more problem -
When i try to fill the arrays at run time using the Form()_Load bit of code, i get the following error:

Run-time error '91': Object variable or With block variable not set.

It highlights a piece of code which says: adodc1.recordset.movefirst

I have managed to fill my arrays using exactly the same code from another form. Is that the problem? Am i not allowed to access the same database from two different forms? Anyway, i'm a bit stuck. Thankyou once again.

Rob.
 
Is that the first reference to Acodc1? Make sure the new form actually has an Ado data control, and set up the connection string and record source properties. If that doesn't work, show me your code.

-Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top