In window textbox, I'd like to just allow decimal only.
For example, 8.56
How to?
In window textbox, I'd like to just allow decimal only.
For example, 8.56
How to?
Private Sub TextBox1_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
You can also do using double.TryParse
.
You can check your input on submit button as below mentioned ways.
double m = 0;
if (double.TryParse(TextBox1.Text, out m) == false)
{
MessageBox.Show("Please enter valid Price");
TextBox1.Focus();
}
else
{
// Put your code here
}