Exjames I alrady used that code in the code I uploaded in your calculator topic. But here I write it for you again:
Code:Private Sub Text1_KeyPress(KeyAscii As Integer) Const allowed_chars As String = "0123456789." 'here add all the characters you want to allow in the textbox Dim char As String If KeyAscii = 8 Then Exit Sub 'this will allow the backspace key. if you don't want to allow the backspace key, they remove this line of code char = Chr(KeyAscii) If Instr(allowed_chars,char) = 0 Then KeyAscii = 0 End Sub




Reply With Quote