Hi All,
I need to amend the code below to cater for only two Decimal places. Anyone know how i can do this?
Thanks
I need to amend the code below to cater for only two Decimal places. Anyone know how i can do this?
Code:
Private Sub TextboxKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress, TextBox7.KeyPress
Dim tb As TextBox = CType(sender, TextBox)
Dim chr As Char = e.KeyChar
If IsNumeric(e.KeyChar) And Not e.KeyChar = "-" Then
e.Handled = Not IsNumeric(tb.Text & e.KeyChar)
ElseIf e.KeyChar = "." Then
If Not (tb.SelectedText = "." Or IsNumeric(tb.Text & e.KeyChar)) Then
e.Handled = True
End If
ElseIf Not Char.IsControl(e.KeyChar) Then
e.Handled = True
End If
End Sub
Thanks
Comment