Question about Initilizing a edittext box

anaylor01

Well-Known Member
Licensed User
Longtime User
I have a button when clicked it checks to make sure there is text in the edittext box. But I get an error saying the edittext box needs to be initialized. Can someone give me of an example of how to do this?
 

kickaha

Well-Known Member
Licensed User
Longtime User
Come on mate, not enough info.

1) Did you add the EditBox using the designer or programatically
2) How are you checking its contents
3) What does the error ACTUALLY say
4) As said on numerous occasions, post some code that demonstrates the error.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Sorry. They were added through the designer. The error:
An error has occurred in sub: Main_btnsend_click (B4A line: 52) If etareacode.text.length > 0 and etprefix.text.length = 0 then java.lang.runtimeexception:Object should first be initialized(EditText).

Code below:
B4X:
If lblfilename.Text.Length = 0 Then 
    If etareacode.Text.Length > 0 AND etprefix.Text.Length = 0 Then
        Msgbox("Please enter a Prefix in the box.","Missing Prefix")
    End If
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Please check that the EditText views are:

1) In the layout that is loaded (check the names are the same)
2) There is a Dim statement for it/them in Sub Globals (again check the names carefully)

The only way I can see this error is if I Dim an EditText that has not been added via a designer layout.
 
Upvote 0
Top