I am trying to bring up a Message Box and halt the program if no data is entered into an Edittext Box
Currently I am using:
B4X:
Sub Button1_Click
If EditText1.Text = " " Then
Msgbox ("Please Enter a Serial Number", "360" )
End If
File.WriteString(File.DirDefaultExternal, EditText1.Text & ".txt" , txtLog.Text)
Msgbox ("Info Saved", "360")
End Sub
In the Old VB6 Days I could use the following:
If Len(edittextbox1.Text) = 0 Then
Msgbox ("Please Enter a Serial Number", "360" )
Exit Sub
End If
Sub Button1_Click
If EditText1.Text.Trim= "" Then
Msgbox ("Please Enter a Serial Number and Click Ok", "360" )
Else
File.WriteString(File.DirDefaultExternal, EditText1.Text & ".txt" , txtLog.Text)
ToastMessageShow ("Info Saved", False)
End If
End Sub
Tip: use MsgboxAsync instead of Msgbox. It is always better and especially inside the Click event. The modal version (Msgbox) can cause a hard crash in some cases.