Quick Question

baron159

Member
Licensed User
Longtime User
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?????
 

derez

Expert
Licensed User
Longtime User
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

rbsoft

Active Member
Licensed User
Longtime User
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:
B4X:
tmp = Main.MyVar

Rolf
 
Upvote 0

poseidon

Member
Licensed User
Longtime User
proper - add it to code module

v6orpy.jpg
 
Upvote 0
Top