CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Textbox help

  1. #1
    Join Date
    May 1999
    Location
    MD, USA
    Posts
    35

    Textbox help

    Is there a way to limit what can be typed into a textbox? For instance, only numbers or letters?

    --
    Screaming Fist
    A witty saying proves nothing.

  2. #2
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    42

    Re: Textbox help

    Hi,

    Yes, we can limit the characters in a textbox. Here is an example which limit the characters to Hexadecimal value:


    private Sub Text1_KeyPress(KeyAscii as Integer)
    Dim strValid as string

    strValid = "0123456789ABCDEF" 'valid input

    KeyAscii = Asc(UCase(Chr(KeyAscii))) 'force uppercase

    If KeyAscii > 26 then 'if not control code
    If InStr(strValid, Chr(KeyAscii)) = 0 then
    KeyAscii = 0
    End If
    End If

    End Sub





    Enjoy yourself and good luck to you.

    Gary Ng



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured