Make text box for price only

  • Thread starter Thread starter AbanoubZak
  • Start date Start date
A

AbanoubZak

Guest
Hello,

My app is connected to MS SQL Server DB and I have a Form contain a TextBox which should be use for price so i need to allow only Numbers and also one "." only, for Ex: 1332.25 or 1332.00

I'm using code which allowing numbers and backspace only and i work fine

Private Sub BasicPrice_KeyPress(sender As Object, e As KeyPressEventArgs) Handles BasicPrice.KeyPress
'97 - 122 = Ascii codes for simple letters
'65 - 90 = Ascii codes for capital letters
'48 - 57 = Ascii codes for numbers

If Asc(e.KeyChar) <> 8 Then
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
End If
End If
End Sub


So what I need is allow also one "." and two numbers after the mark so any idea?

Thanks in advance.

Continue reading...
 
Back
Top