P patrickfailing New Member Licensed User Longtime User Sep 11, 2014 #1 I have a regular edittext box with numbers only. When I press done with the box being empty I get the number format exception, Invalid double. I need to know how to set it so that if this happens and an empty string is sent that I can either insert an alert or put in a set value and not have the edittext box close. Any help would be greatly appreciated. Thanks. Code: Copy Sub EditText1_EnterPressed If EditText1.Text > 1000 Then EditText1.Text = 1000 If EditText1.Text < 1 Then EditText1.Text = 0 Packet = "f" & EditText1.Text astreams.Write(Packet.GetBytes("UTF8")) ToggleButton1.Checked = False
I have a regular edittext box with numbers only. When I press done with the box being empty I get the number format exception, Invalid double. I need to know how to set it so that if this happens and an empty string is sent that I can either insert an alert or put in a set value and not have the edittext box close. Any help would be greatly appreciated. Thanks. Code: Copy Sub EditText1_EnterPressed If EditText1.Text > 1000 Then EditText1.Text = 1000 If EditText1.Text < 1 Then EditText1.Text = 0 Packet = "f" & EditText1.Text astreams.Write(Packet.GetBytes("UTF8")) ToggleButton1.Checked = False
C cyiwin Active Member Licensed User Longtime User Sep 12, 2014 #2 Not sure if this helps with an empty string but you may want to try IsNumber. Code: Copy If IsNumber(EditText1.Text) = True Then .... End If or assign a variable to EditText1 Code: Copy Dim Ans As Double Ans = EditText1.Text If IsNumber(Ans) = True Then ..... End If Upvote 0
Not sure if this helps with an empty string but you may want to try IsNumber. Code: Copy If IsNumber(EditText1.Text) = True Then .... End If or assign a variable to EditText1 Code: Copy Dim Ans As Double Ans = EditText1.Text If IsNumber(Ans) = True Then ..... End If
Erel B4X founder Staff member Licensed User Longtime User Sep 12, 2014 #3 IsNumber will return false for empty strings. The first code snippet will work. Upvote 0
P patrickfailing New Member Licensed User Longtime User Sep 12, 2014 #4 Thank you for confirming my suspicions. I appreciate your help. Love the program by the way. Upvote 0