Tag Archives: allowed characters

Allow only certain characters in a textbox using VB 6.0

Shows how to use Visual Basic 6.0 (VB 5.0 as well) to only allow certain, specific characters in a textbox control.

        '1 textbox ‘put in keypress procedure of textbox
        Const Numbers$ = "0123456789."

        If KeyAscii <> 8 Then

            If InStr(Numbers, Chr(KeyAscii)) = 0 Then


                KeyAscii = 0

                Exit Sub

            End If

        End If