Hi go thr this |
| Sujit Patil replied to divya rocks at 12-May-08 03:07 |
Public Sub TextBox1_Validating(ByVal sender As Object, _ ByVal e As System.ComponentModel.CancelEventArgs) _ Handles TextBox1.Validating
try { int value=Int32.Parse(this.Text); } catch(Exception) { e.Cancel=true; MessageBox.Show("Please Enter Numeric Value"); }
OR Do like this;
int keyCode= Convert.ToInt16(e.KeyChar);
if ((keyCode >= 97 && keyCode <= 122) || (keyCode == 8))
{
e.Handled = false;
}
else
{
e.Handled = true;
MessageBox.Show("Please Enter Numeric Value");
}
End Sub
Just go thr these links you will find it.
http://www.java2s.com/Code/VB/GUI/TextBoxValidatingEvent.htm
http://www.csharphelp.com/archives/archive64.html
http://www.csharphelp.com/archives/files/archive64/NumberBox.cs
Best Luck!!!!!!!!!!
Sujit. |
|