G
Guest
I have written the following code which allows user to enter only numbers and
only one decimal point. This works fine.
However, I want that user shouldn't enter a third number after decimal
point, for example user should not be allowed to enter 12557.234. User should
only be allowed to enter two digits after decimal point.
I know I can validate it in the validate event, however, I was wondering if
some can modify the following code so that it be done in keypress event.
Thanks in advance!
If Asc(e.KeyChar) <> Keys.Back Then
If e.KeyChar.IsNumber(e.KeyChar) = False Then
If e.KeyChar <> "." Then
ze.Handled = True
Else
If txtAmountFigure.Text.IndexOf(".") <> -1 Then
e.Handled = True
End If
End If
End If
End If
only one decimal point. This works fine.
However, I want that user shouldn't enter a third number after decimal
point, for example user should not be allowed to enter 12557.234. User should
only be allowed to enter two digits after decimal point.
I know I can validate it in the validate event, however, I was wondering if
some can modify the following code so that it be done in keypress event.
Thanks in advance!
If Asc(e.KeyChar) <> Keys.Back Then
If e.KeyChar.IsNumber(e.KeyChar) = False Then
If e.KeyChar <> "." Then
ze.Handled = True
Else
If txtAmountFigure.Text.IndexOf(".") <> -1 Then
e.Handled = True
End If
End If
End If
End If