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.