Validating integer input

windows

Guest
How do you validate a textbox for a integer value in VB or C#. I have a shopping cart where a person can type in an integer value for quantity. How would I go about validating the textbox to check for non-numeric values?You can use a regular expression. Turn the string into a char array and check each character. Or for at least VB you can use IsNumeric.


If IsNumeric(txtBox1.Text.Trim) Then
'Do something when is numeric
Else
'Do something when not is numeric
End If
 
Back
Top