Hi,
I need some help please. I developed a Customer Management System, were there is a form to input information. My program works fine when inputting letters and numbers to the form. But when I input special characters ,it starts to send error message. How can i fix my code, so that special characters wont be a problem.
Thank you very much.
Elmer.
- Login or Signup Now to post comments

Inputting Special Characters on form resulting to Error in Visual Basic Code
There are characters that Visual Basic is using when making Visual Basic Codes. This includes the following list of characters:
The above listed characters are all reserved. There are instances using those characters raised and error in your program especially on input values.
Commonly the Double Quotes (“) and the Single quote (‘) generates error when saving to database or storing into values. For example we have an input box in our form where the fields sometimes used double quotes. Let’s say the field input is height, sometimes we input the seven feet and three inches like this: 7’3”. Note: we have used the character Double and Single Quotes. Then this input field will be assigned to a string or text field on a database. Our query statement will goes like this:
CONN.EXECUTE “INSERT INTO Table1 ( test ) VALUES (‘" & TEXT1.TEXT & "’)”;
The statement equals with this:
CONN.EXECUTE “INSERT INTO Table1 (test) VALUES (‘7’3”’);
As you can see the value 7 is enclosed with a single quotation. When the statement interprets by the visual basic compiler, the 3” does not belong to the statement and occurred to be syntax error.
Solution for this anomaly in your program is to generate a module or function that detects for the single quotation and double quotation in the string and double each quotation. For example a double quotes goes like this (“”) while single quotation goes like this (‘’). Visual basic interpreter interprets that the double double-quote inside the enclosed string is a just a double quote as well as the single quote.
If you can’t debug your system, in your input field double the quotes instead of using just one. 7’3” will goes like this: 7’’3””.
All you have to do is to design an error handling module to handle the special character entered by the user and then show an error message to the user if any of the pressed character is a special character. you can handle it by two ways :
1. Everytime a special character is entered by a user, check if the entered character is a special character and take input again for that variable.
2. Take the input from the user, check if it contains any special characters and then remove those characters from the string before progam moves further.
3.If you want to have those special character then write a module which will replace any special character entered by user with a predefined number and then procces it.
Basically you need to deal with those special character, as soon as user enters it.
mactech