?
Solved

Microsoft VBScript runtime error '800a005e'

Posted on 2009-02-10
1
Medium Priority
?
595 Views
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

0
Comment
Question by:gimby
1 Comment
 
LVL 7

Accepted Solution

by:
DarkHill earned 500 total points
ID: 23601187
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)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question