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?
VBScript Dictionary Objects. A Dictionary object can be compared to a PERL associative array. Any Values can be stored in the array and each item is associated with a unique key. The key is used to retrieve an individual element and it is usually an integer or a string, but can be anything except an array.
The Dictionary object is used to hold a set of data values in the form of (key, item) pairs. A dictionary is sometimes called an associative array because it associates a key with an item.
The key is used to retrieve an individual element and it is usually an integer or a string, but can be anything except an array. VBScript classes are enclosed within Class .... End Class. <!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> Dim obj_datadict ' Create a variable.
To retrieve the item value for a given key, use the .Item property. This is the default property for a Dictionary object. For example: The Rhino.Print statement displays the item value stored in the dictionary for the "Salami" key.
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.
Yes, you need to use the SET command:
Set queryCleanForm = myDictForm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With