We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Microsoft VBScript runtime error '800a005e'

gimby asked
Medium Priority
Last Modified: 2012-05-06
I had a ASP Function that has been working fine to add left or right padding to a string. Something must have changed on the server as I now get a
Microsoft VBScript runtime error '800a005e'
Invalid use of Null
<%Function Lpad (MyValue, MyPadChar, MyPaddedLength)
Lpad = string(MyPaddedLength - Len(MyValue),MyPadChar) & MyValue
End Function
Function Rpad (MyValue, MyPadChar, MyPaddedLength)
Rpad = MyValue & string(MyPaddedLength - Len(MyValue), MyPadChar)
End Function %>

Open in new window

Watch Question

This error will occur when trying to determine the Len of a Null value (usually from a database query). I assume the call to your function will always MyPadChar and MyPaddedLength variables set, the only wildcard will be MyValue. You can do a check on that value (using isNull function - http://www.w3schools.com/vbScript/func_isnull.asp) or the even faster solution is to simply add an empty string to it, e.g. add this line in your function:

MyValue = MyValue & ""

So your whole functions will be:

<%Function Lpad (MyValue, MyPadChar, MyPaddedLength)
MyValue = MyValue & ""
Lpad = string(MyPaddedLength - Len(MyValue),MyPadChar) & MyValue
End Function
Function Rpad (MyValue, MyPadChar, MyPaddedLength)
MyValue = MyValue & ""
Rpad = MyValue & string(MyPaddedLength - Len(MyValue), MyPadChar)
End Function %>

You can even do it inline, e.g. Rpad = MyValue & "" & string(MyPaddedLength - Len(MyValue & ""), MyPadChar)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.