Textbox control accepts only one "." character ex.. Like "23.45" and not "23.4.5"?

Muhilan
Posted by Muhilan under VB.NET category on | Views : 3903
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) > 47 And Asc(e.KeyChar) < 58 Or Asc(e.KeyChar) = 46 Then
If TextBox1.Text.IndexOf(".") <> -1 And e.KeyChar = "." Then
e.Handled = True
End If
Else
e.Handled = True
End If
End Sub

Comments or Responses

Login to post response