i am using vb6.
in a form i had a text box where i only want to accept numeric values
it may be decimal value
so i use the following code in key press event of the textbox
the code is working fine the problem arises
when the user mistaken writes some values like this
as i am also doing some more calculations in it so it give error .
so how to avoid this . what is the solution?
thanks
in a form i had a text box where i only want to accept numeric values
it may be decimal value
so i use the following code in key press event of the textbox
Code:
Private Sub amounttxt_KeyPress(KeyAscii As Integer) Dim comp As Boolean comp = Chr(KeyAscii) Like "[0-9.]" If Chr(KeyAscii) = vbBack Then Exit Sub If comp = False Then KeyAscii = 0 End If End Sub
when the user mistaken writes some values like this
Code:
200.62.365 instead of 20062.365 or 20..36 instead of 20.36 (by mistake user may enter two time decimal in the box )
so how to avoid this . what is the solution?
thanks
Comment