Declare var into codemoduls

volvomann

Active Member
Licensed User
Longtime User
How to Declare an EditText so it can be read all code modules. I get the error if I put it into the Sub Process_Globals (Error description: Cannot access activity object from sub Process_Globals.)
I have tried many things in for many houers and no I take a big break
 
I will get to it are:
In the main:

SubButton1_Click
Trykk.bergne
End Sub

Code module, Trykk

Sub beregne the

Dim areal As int
areal=editext.text
........................
.........................

End Sub
How can I read editext1.text


Sorry for bad English
 
Upvote 0
Activity objects "die" when the Activity is closed(Activity.Finish). Therefore, you can't access them this way. You should reverse your logic (access CodeModules from Activities).

Code module:
Code: Copy
Sub doIt(txt as EditText)
    txt.Text = "My value was set by the CodeModule doIt() method"
End Sub

In your Activity:

Code: Copy
'In Globals:
Dim theField as EditText

'In Activity_Create or wherever
CodeModuleName.doIt(theField)

Another examples have been posted above by Erel and Klaus.
 
Upvote 0
Back
Top