how do you catch non alphanumeric characters?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • obkfixx
    New Member
    • Mar 2008
    • 19

    how do you catch non alphanumeric characters?

    help.. i have a problem.. how do u catch non alphanumeric characters??
    it created an error on my program since the field type on the database is varchar...
    when i inputed admin\ on the username.... it creates a runtime error
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try handle the KeyAscii of the keystrokes.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      You really have two approached that should be considered, and they're not mutually exclusive.
      • You can filter/restrict user input in various ways, including tests of the characters entered (as Debasis pointed out), and/or the use of a "special" control such as the MS Masked Edit control.
      • You can trap errors which occur at runtime and deal with them gracefully, rather than allowing the code to simply crash. For instance, if you hit an error connecting to the database, rather than simply crashing with some cryptic error message you could warn the user with a pop-up window, then either close or allow them to try again. Also, the specific error number which is trapped may (or may not) tell you what the problem is.

      A lot of the specifics will depend on what version of VB you're using, and probably also on what type of database you're dealing with. Since you mention varchar, I assume it's not MS Access.

      Comment

      Working...