I have a button called Button1 in a pressed event
I want to check that the “prenom” field isn’t empty so I can continue the code, but it’s stuck, the loop continues even if I insert text and press the button again!
Do Until Prenom.Text = ""
Prenom.tooltip ="You must enter something"
Loop
FileUploader1.StartUpload
Label1.Visible=False
You really sould not have a loop like this; it will block the user interface.
You should have a message area where you report user errors. Then if Prenom is empty you report to the user that they must enter a name. When the name is non-empty and (important!) non-blank then your pressed event can take some action.
This code will continue around the do loop forever once the button1 is pressed - it is not giving the prenom textfield chance to enter anything.
Try something simpler like:
If prenon.text = “” then return
Note that if you have already set the tooltip, e.g. in the open event, then it will show automatically when the text is “”.
Or even:
If prenom.text.trim() = "" then return
1 Like
I know this could go on forever but you could add to prenom.textChanged event:
button1.enabled = me.text.trim() <> ""