senators40
Technical User
Hi,
I have a textbox in a userform. I have used the following commands to tell people to enter numbers only. Unfortunately if the user were to enter 50,00 (misplacing the comma) the vb code will still think this is a number and cause an error in the further code (adding the numbers into a final textbox (ie textbox1 + textbox2 = textbox3).
This also seems to have a problem with $ and + , at the beginning and end of the numbers as well.
The following is the code that I am using.
'To make sure that the person enters a number
If TextBox1 = vbNullString Then Exit Sub
If Not IsNumeric(TextBox1) Then
MsgBox "Sorry, numbers only"
TextBox1 = vbNullString
End If
Does anyone have any suggestions.
Also acceptable would be to remove the comma's automatically if the user enters them into the textbox
Thanks
Jeff
senators40@hotmail.com
I have a textbox in a userform. I have used the following commands to tell people to enter numbers only. Unfortunately if the user were to enter 50,00 (misplacing the comma) the vb code will still think this is a number and cause an error in the further code (adding the numbers into a final textbox (ie textbox1 + textbox2 = textbox3).
This also seems to have a problem with $ and + , at the beginning and end of the numbers as well.
The following is the code that I am using.
'To make sure that the person enters a number
If TextBox1 = vbNullString Then Exit Sub
If Not IsNumeric(TextBox1) Then
MsgBox "Sorry, numbers only"
TextBox1 = vbNullString
End If
Does anyone have any suggestions.
Also acceptable would be to remove the comma's automatically if the user enters them into the textbox
Thanks
Jeff
senators40@hotmail.com