Forum Home
Press F1
 
Thread ID: 25821 2002-10-12 23:21:00 Visual Basic help required Nigel Thomson (629) Press F1
Post ID Timestamp Content User
88737 2002-10-12 23:21:00 Hello I am a very stuck student
the problem is,
I am writing a program and have created an array whose size has been set by reading a text file in, then using the Redim (a requirment) to set the size of the array to the number of lines in the text file,
the problem is
I can't work out how to call the array from other procedures, is there a way I can make the Array global, I think it may be possible using the PUBLIC statement but can I do that in the middle of a procedure?
any help would be appreciated
Nigel T
Nigel Thomson (629)
88738 2002-10-12 23:43:00 Hi nige, you could just initialise the array before anything else gets done, ie at the top of the page, then it will be global and all can access it.
Do you want to call the array, or do you want to call the function that has the array, - what do you want it to do?
Have fun anyway :)
raddersnz (684)
88739 2002-10-12 23:56:00 Firstly are you sure you have passed the array as an argument to the procedure. I haven't done VB in such a long time, but if my memory serve me well then you need to pass it like it was just another variable.

/this is hurting my head ....

precedure.name(array.name(), variable1, variable2, ... )
{
statements ...
}
end.

... hell, something like that!

Try different approaches to the same problem. Instead of passing the array to the procedure try passing the value the dynamic array is to be redimensioned to and redim the array in main (hmmm ... VB does have main right? .. yeah of course it does ... does it?).

Okay, my memory of VB is rather vague but the point is there is more then one way to solve a problem. Based specifically on your question your problem seems to be a syntax one. If you can't find the appropriate syntax then work with the syntax you know and develope an algorithm appropriate to your knowledge.
helvista (1745)
88740 2002-10-13 00:53:00 Thanks for your help just after posting I found apage that explained the Public statement and have now got it to work properly
See ya later
Nigel Thomson (629)
88741 2002-10-13 02:15:00 I please you've found a solution, though I do have a question. Would your tutor/lecturer be unimpressed if you made a variable public (due to security reasons)? helvista (1745)
1