02 May 2012

Why I use ANSI values for certain characters in VBscripts

Some people think it is weird that I use the ANSI values in all of my VBScripts, but there is a good reason for it. There have been times when code that I have written needed to be debugged. The error was hard to find in the code, especially when it came down to a space. After several times of this, I changed to specifying spaces with their ANSI value so that it is easy to identify them.

I also extended the use of ANSI values to other characters such as the quotation mark, as such that when defining a string variable and a quotation mark is needed with the string, it is not possible to use a quotation mark because of the necessary ones at that beginning and end.

Another character I use ANSI for is the carriage return, as it is not possible to do otherwise. My suggestion is to always keep a printed ANSI table on your desk as a reference while coding. When you go back and debug code in such instances, you will be glad that you did this!


Post a Comment