I have a textbox and I am using the following to validate the user can only add numbers, but how can I let the user to write only one “.”
Private Sub txtDiagnostic_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtConsultor.KeyPress
If e.KeyChar <> ChrW(Keys.Back) Then
If Char.IsNumber(e.KeyChar) Then
Else
e.Handled = True
End If
End If
End Sub
I was planing to use contains() or something but how can I realize the textbox has
only one dot? or how to allow the user can write a single dot and only one?
add this line before your first
IF