Allow only certain characters in a textbox using VB 6.0

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.