Article ID: 80411 - Last Review: August 16, 2005 - Revision: 2.1 "Illegal Function Call" Using Asc with Uninitialized StringThis article was previously published under Q80411 On This PageSUMMARY
If you try to use the Asc function on a string that has been
initialized to a value of null (""), you will correctly receive an
"Illegal function call" error message. The string must be assigned to
a value other than "" (the null string) for the Asc function to return
the ASCII value of the first character in the string.
MORE INFORMATION
This information is documented in the QB.EXE 4.5 or QBX.EXE 7.0/7.1
online Help for the Asc function, but is not available when the error
message is received when the Help option is chosen. Below are two code
examples that reproduce the error. By assigning the string to any
value, the Asc function works without error.
The following code examples will fail: Code Error Example 1Code Error Example 2Correct Code Example 1Correct Code Example 2To work around the error, check the length of the string with the Len function in an IF...THEN statement to ensure it is greater than zero before passing the string as an argument to the Asc function. The following code example demonstrates the workaround. The code allows you to only use the Asc function when something has been assigned to the string, otherwise it sets the Asc value to zero. Assigning Temp$ to CHR$(0) returns a 0, but assigning it "" gives you an "Illegal function call". APPLIES TO
| Article Translations
|

Back to the top
