K
Keith
The following control code - only allows for the entry of
numbers, backspace, and decimals (or periods). The
problem lies in the last statement - it allows multiple
decimals or periods. How would I modify the code to only
allow 1 decimal? In other words - once a user entered one
period - no others could be entered?
Private Overloads Sub TextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
Dim isKey As Boolean = e.KeyChar.IsDigit(e.KeyChar)
Dim isDecimal As Boolean = e.KeyChar.ToString = "."
Dim MyChar As String = Chr(8)
Dim isBackspace As Boolean = e.KeyChar.ToString =
MyChar
If Not isKey And Not isDecimal And Not isBackspace
Then
e.Handled = True
End If
End Sub
thank you.
numbers, backspace, and decimals (or periods). The
problem lies in the last statement - it allows multiple
decimals or periods. How would I modify the code to only
allow 1 decimal? In other words - once a user entered one
period - no others could be entered?
Private Overloads Sub TextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
Dim isKey As Boolean = e.KeyChar.IsDigit(e.KeyChar)
Dim isDecimal As Boolean = e.KeyChar.ToString = "."
Dim MyChar As String = Chr(8)
Dim isBackspace As Boolean = e.KeyChar.ToString =
MyChar
If Not isKey And Not isDecimal And Not isBackspace
Then
e.Handled = True
End If
End Sub
thank you.