How would I create a command that checks to see the text in a textbox and if its not numeric then to display a message..
For example..
:confused:Code:Private Sub cmdgo_Click()
If Text1.text = Not Numeric Then
Msgbox "Not Numeric"
End If
Thankyou
Printable View
How would I create a command that checks to see the text in a textbox and if its not numeric then to display a message..
For example..
:confused:Code:Private Sub cmdgo_Click()
If Text1.text = Not Numeric Then
Msgbox "Not Numeric"
End If
Thankyou
Code:Private Sub cmdgo_Click()
If IsNumeric(Text1.text) =False Then
Msgbox "Not Numeric"
End If
This will help you
http://www.vbforums.com/showthread.php?t=507097
Code:If Not IsNumeric(Text1.Text) Then
That's another way to use my code Zach_VB6 ;)
Check this control out:
http://www.vbforums.com/showthread.php?t=510567
Note that if the textbox reads "1/2", IsNumeric will say that it is not numeric because the forward slash is not considered a numeric by IsNumeric. Some might consider this a weakness. Other examples can also be identified, such as the factorial sign !, brackets, and braces. On the other hand, parentheses are considered numeric, so I think there is some judgment calls going on here.Quote:
Originally Posted by Zach_VB6
Just my $0.02.
You could
n Code:
Private Sub cmdgo_Click() text1.text = replace (text1.text,"/","") If IsNumeric(Text1.text) =False Then Msgbox "Not Numeric" End IfQuote:
Originally Posted by Code Doc
Code Doc is correct. A one size fits all approach through IsNumeric() is not always appropriate because of the way the function works, e.g. "2E5" returns True but that isn't so for an IP address octet or a cash amount. And newprogram, "1//2" should not be a valid expression.