S Spacewalker Member Licensed User Longtime User Oct 20, 2012 #1 Hello, I have a problem with global variables: I have 2 modules: Main Activity2 in Main I declare a process_global variable "iTXTSize" as follows: Code: Copy 'Activity module Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim iTXTSize As Int End Sub and also in Main I assign a value to iTXTSize and call another Activity like this: Code: Copy Sub btnSizeOK_Click iTXTSize = txtSize.text CallSubDelayed (Activity2,"StartProg") End Sub in Activity2 I want to use the process_global variable iTXTSize: Code: Copy sub StartProg() Msgbox ("Activity2: Size="& iTXTSize,"") 'here ERROR end sub But I get an error: Error description: Undeclared variable 'itxtsize' is used before it was assigned any Why is this? I thought that a process_global variable should be available in all modules? thx Heinz
Hello, I have a problem with global variables: I have 2 modules: Main Activity2 in Main I declare a process_global variable "iTXTSize" as follows: Code: Copy 'Activity module Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Dim iTXTSize As Int End Sub and also in Main I assign a value to iTXTSize and call another Activity like this: Code: Copy Sub btnSizeOK_Click iTXTSize = txtSize.text CallSubDelayed (Activity2,"StartProg") End Sub in Activity2 I want to use the process_global variable iTXTSize: Code: Copy sub StartProg() Msgbox ("Activity2: Size="& iTXTSize,"") 'here ERROR end sub But I get an error: Error description: Undeclared variable 'itxtsize' is used before it was assigned any Why is this? I thought that a process_global variable should be available in all modules? thx Heinz
P praetor100 New Member Oct 20, 2012 #2 I think you should write main.iTXTSize in the Activity2. Upvote 0
E edgar_ortiz Active Member Licensed User Longtime User Oct 23, 2012 #3 In fact, you need: Code: Copy sub StartProg() Msgbox ("Activity2: Size="& numberformat2(main.iTXTSize,1,0,0,false),"") end sub In Msgbox, you can only use strings, Regards, Edgar Upvote 0
In fact, you need: Code: Copy sub StartProg() Msgbox ("Activity2: Size="& numberformat2(main.iTXTSize,1,0,0,false),"") end sub In Msgbox, you can only use strings, Regards, Edgar
agraham Expert Licensed User Longtime User Oct 23, 2012 #4 edgar_ortiz said: In Msgbox, you can only use strings, Click to expand... Only partly true. Basic4android will convert any non-string types for you using the ToString() method of that type. It will do this anywhere and not only where strings are expected, it will try to convert any type to the expected type. Upvote 0
edgar_ortiz said: In Msgbox, you can only use strings, Click to expand... Only partly true. Basic4android will convert any non-string types for you using the ToString() method of that type. It will do this anywhere and not only where strings are expected, it will try to convert any type to the expected type.