CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    15

    Don't use symbols...

    How can I stop certain symbols such as / \ : * ? < > | from being used in a text box?

    Jonathon.


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Don't use symbols...

    Edit them out something like this

    private Sub Text1_KeyPress(KeyAscii as Integer)
    Dim NoWant as string
    NoWant = "/ \ : * ? < > "
    If NoWant Like "*" & Chr$(KeyAscii) & "*" then KeyAscii = 0
    End Sub




    John G

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Don't use symbols...

    You might want to remove the spaces from the string "NoWant"?

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Don't use symbols...

    Got a point there

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Don't use symbols...

    Did not notice that. It appears to be a flaw in Cut and Paste because I cut and pasted that string directly from the original post which does not have the spaces.
    Will try it again to see what happens.

    John G

  6. #6
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Don't use symbols...

    I lied. The original post does have the spaces.

    John G

  7. #7
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Don't use symbols...

    Yeahyeah, blame it on someone else

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  8. #8
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    15

    Re: Don't use symbols...

    Thanks John,

    Tried it, and it works perfecly,

    Jonathon.


  9. #9
    Join Date
    Jul 2001
    Location
    maharashtra,india
    Posts
    181

    Re: Don't use symbols...

    on keypress event
    u can check its keyascii
    suppose u want to cancel "a space" who's keyascii=32
    if keyascii=32 then
    keyascii=0
    end if
    or else if u dont know the keyascii then
    if(keyascii=asc("/")) then
    keyascii=0
    end if
    best of luck


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