views:

216

answers:

1

I'm using old VBScript in my ASP application. Trying to search and replace string using Replace(wholeText, textToSearch, textToReplace) function but i'm getting the following error:

Microsoft VBScript runtime  error '800a005e'

Invalid use of Null: 'Replace'

/instance/inst_spam_gen_4.asp, line 25

And here is my function:

Function cleanUpText(txt)

     txt = Replace(txt, "“", """")
     txt = Replace(txt, "”", """")
     txt = Replace(txt, "’", "'")
     txt = Replace(txt, "®", "®")

    cleanUpText = txt
End Function

How can I solve this problem?

Thanks

+4  A: 

The problem is not in the function that you are showing, but in the code that is calling the function.

You have gotten a result from the database that contains a Null value. You are then calling the function with that value, which causes the error.

If Null values is supposed to be valid in the data, you can use the IsNull() function to check for those, so that you don't use the value for anything that can't handle them.

Guffa