views:

29

answers:

2

I have a dictionary of form data that I want to modify using a function.

function queryCleanForm(myDictForm)

    dim arrayKeys
    arrayKeys = myDictForm.keys

    for i=0 to myDictForm.count-1
        myDictForm(arrayKeys(i)) = replace(myDictForm(arrayKeys(i)), "'", "''")
        response.write myDictForm(arrayKeys(i))
    next

    queryCleanForm = myDictForm
end function

The problem is the line queryCleanForm = myDictForm errors as

Wrong number of arguments or invalid property assignment 

Is there a way to do this in VBScript?

+1  A: 

Yes, you need to use the SET command:

Set queryCleanForm = myDictForm

Anzoid
+2  A: 

Try this:

SET queryCleanForm = myDictForm

With objects you need to use SET to tell VBScript that it is an object reference you are assigning not a value type.

JohnFx
thanks... that is painfully obvious now :-)
quakkels
This gotcha gets all VB/VBScript/VBA developers at least a few dozen times in their careers. One of the more annoying features of the language.
JohnFx