volvomann Active Member Licensed User Longtime User Mar 24, 2012 #1 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
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
klaus Expert Licensed User Longtime User Mar 24, 2012 #2 Views, like EditText , belong to an Activity so you cannot declare them in Process_Globals but only in Globals. What you can do is transmit the EditText as a parameter in a sub call. Best regards. Upvote 0
Views, like EditText , belong to an Activity so you cannot declare them in Process_Globals but only in Globals. What you can do is transmit the EditText as a parameter in a sub call. Best regards.
volvomann Active Member Licensed User Longtime User Mar 24, 2012 #3 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
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
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2012 #4 Pass the view to the sub: Code: Copy Sub beregne(et As EditText) areal = et.Text End Sub Upvote 0
klaus Expert Licensed User Longtime User Mar 24, 2012 #5 Try this code: Code: Copy Sub Button1_Click Trykk.bergne(EditText1) End Sub Code module, Trykk Code: Copy Sub bergne(edt as EditText) Dim areal As int areal=edt.text ........................ End Sub Best regards. Upvote 0
Try this code: Code: Copy Sub Button1_Click Trykk.bergne(EditText1) End Sub Code module, Trykk Code: Copy Sub bergne(edt as EditText) Dim areal As int areal=edt.text ........................ End Sub Best regards.
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2012 #6 Sorry for jumping in... Upvote 0
klaus Expert Licensed User Longtime User Mar 24, 2012 #7 Don't worry, at least we give the same solution . Best regards. Upvote 0
margret Well-Known Member Licensed User Longtime User Mar 24, 2012 #8 Can you not also acces them from a code module like: Code: Copy main.MyEditText.Txt = "What I want Here" Upvote 0
Can you not also acces them from a code module like: Code: Copy main.MyEditText.Txt = "What I want Here"
P Penko Active Member Licensed User Longtime User Mar 25, 2012 #9 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
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.