baron159 Member Licensed User Longtime User May 28, 2012 #1 I know this is most likely a stupid question but i can't figure it out for the life of me. I need a variable to be available to all Modules so this is the location of the sub and everything else Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim trait As String End Sub But yet when I go to the other Modules i can't pull up the value of "trait", I tried declaring it again same sub on the other module but still no go... what am i not doing?????
I know this is most likely a stupid question but i can't figure it out for the life of me. I need a variable to be available to all Modules so this is the location of the sub and everything else Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim trait As String End Sub But yet when I go to the other Modules i can't pull up the value of "trait", I tried declaring it again same sub on the other module but still no go... what am i not doing?????
J Jost aus Soest Active Member Licensed User Longtime User May 28, 2012 #2 You must prefix the variable name with the module name where it belongs to. Upvote 0
derez Expert Licensed User Longtime User May 28, 2012 #3 Although the variable is known in all modules, you still have to call it by the modulename (where it is declared) and dot before the variable name, like main.trait . Upvote 0
Although the variable is known in all modules, you still have to call it by the modulename (where it is declared) and dot before the variable name, like main.trait .
baron159 Member Licensed User Longtime User May 28, 2012 #4 Could I get an Example please? if it's not too much Upvote 0
rbsoft Active Member Licensed User Longtime User May 28, 2012 #5 Example: In your activity Main your have declared MyVar as global variable. You want to use this variable in your code module xyz.bas. You would do it like this: Code: Copy tmp = Main.MyVar Rolf Upvote 0
Example: In your activity Main your have declared MyVar as global variable. You want to use this variable in your code module xyz.bas. You would do it like this: Code: Copy tmp = Main.MyVar Rolf
P poseidon Member Licensed User Longtime User May 28, 2012 #6 proper - add it to code module Upvote 0