Android Question Can't read properties of the same control who's event just fired

Christian Blackburn

Member
Licensed User
Longtime User
In the designer, I chose generate members. However, even inside of the text box's own event handler I still can't access properties of the control in question without some kind of qualifier which is? By the way this is just an example I'm not actually trying to hide the control.

Thanks for your assistance,
Christian Blackburn

Sub txtStudent_ID_TextChanged (Old As String, New As String)
txtStudent_ID.Visible = False
End Sub


Error description: Undeclared variable 'txtstudent_id' is used before it was assigned any value.
Occurred on line: 72 (Main)
txtStudent_ID.Visible = False

 

RandomCoder

Well-Known Member
Licensed User
Longtime User
When generating the members did you also select the first checkbox next to the object name? It will add a declaration at the top of your program in Sub Globals.
You can also add it manually...
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim txtStudent_ID As EditText
End Sub
 
Upvote 0

Christian Blackburn

Member
Licensed User
Longtime User
Hi RandomCoder,

Thank you ever so much. There should be a different set of check boxes for that. I realize you could have a label and never need to reference it with code, but checking a parent box inherently means you want all the child events.
Generate Members Checkboxes.png


Thanks,
Christian Blackburn
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
I agree, instinctively you would expect that checkbox to select all associated events.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
but checking a parent box inherently means you want all the child events
it means you are able to generate multiple members at once.

B4X:
Sub txtStudent_ID_TextChanged (Old As String, New As String)
txtStudent_ID.Visible = False
End Sub
here you have set the eventname to the name of the object. This will result in an event sub for THIS object. But not other edittexts.

You surely can use a different eventname and set this eventname to some or all of your edits. You are then able to access them all from withn ONE eventsub.

B4X:
Sub edt_TextChanged (Old As String, New As String)
  dim et as edittext = sender
  et.Visible = False
End Sub
 
Upvote 0
Top