B4J Question Check if textfield is not empty

ThRuST

Well-Known Member
Licensed User
Longtime User
This question could possible be posted in any of the other forums but I try here.
Might seem simple but this got me puzzled:

How to check if textfield is empty or not? I have tried
B4X:
If textfield.text !="" then
   code...
End If
But that didn't work. I think that worked in VB.NET years ago...
 
Last edited:

ThRuST

Well-Known Member
Licensed User
Longtime User
I solved it myself this way
B4X:
If textfield.Text = "" Then
   Return
Else
   code...
End If
If you know a simpler way let us know :)
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
plenty ways to check that, both above are correct, and you could even do it like
B4X:
If TextField.Text.length<>0 then
But then again, a space would make it true
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Yay, both ways works fine.
But I personally like Squiffys way but Cableguys solution was kinda clever too. It was good to refresh our memory on this, simple matter :D Thanks
 
Upvote 0
Top