Local and global variablesby Solitaire (Login Solitaire1)S Any variables or arrays that you DIM inside a sub are local and are not remembered by any other sub. Local variables stay in memory only as long as the sub code executes, and then they die. If you want to share the variables or arrays throughout the entire program, then you need to either learn how to pass arguments to the parameters in the sub, or declare the variables/arrays as global at the top of the main program:
DIM SHARED myarray(1 TO 21) AS STRING for a static array or REDIM SHARED myarray(1 TO n) AS STRING for a dynamic array. Try it both ways and see which works for your program. |