R
Ryan Malone
Passing Dictionary object byref
Ive created an ASP class that uses a dictionary object which is filled
from a recordset. It passes the object to the propterty of another ASP
class byref:
Public Property Let dicReplaceVars(byref vdicReplaceVars)
set p_ReplaceVars = vdicReplaceVars
End Property
Private p_ReplaceVars
where it is used in this other class a few times to replace values in
an array:
Function ReplaceVars(vArrayItem)
' turn it into an array split at spaces
vArrayItem = split(vArrayItem," ")
' loop through the array
for count = lbound(vArrayItem) to ubound(vArrayItem)
'See if it is a replacement variable and exists in the dictionary
if left(vArrayItem(count),6) = "tkRep_" and
p_ReplaceVars.exists(vArrayItem(count)) then
' then replace it
Error occurs here >> vArrayItem(count) =
p_ReplaceVars.Item(cstr(vArrayItem(count)))
end if
next
dim vArrayItemNew
vArrayItemNew = ""
' Loop through the array and put it back together
for count = lbound(vArrayItem) to ubound(vArrayItem)
if vArrayItem(count) = ubound(vArrayItem) then
vArrayItemNew = vArrayItemNew & vArrayItem(count)
else
vArrayItemNew = vArrayItemNew & vArrayItem(count) & " "
end if
next
' return the vArrayItemNew to the function
ReplaceVars = vArrayItemNew
End Function
The error message I get is:
ADODB.Field (0x800A0D5C)
Object is no longer valid.
D:\WWW\LCDEV\DOC_FUNCTIONS\../classes/classlcDocTKit_item.asp, line 52
However I have no idea why, it is a dictionary object and not a
recordset, the object should still be open.
Any help is greatly appreciated.
Thanks
Ive created an ASP class that uses a dictionary object which is filled
from a recordset. It passes the object to the propterty of another ASP
class byref:
Public Property Let dicReplaceVars(byref vdicReplaceVars)
set p_ReplaceVars = vdicReplaceVars
End Property
Private p_ReplaceVars
where it is used in this other class a few times to replace values in
an array:
Function ReplaceVars(vArrayItem)
' turn it into an array split at spaces
vArrayItem = split(vArrayItem," ")
' loop through the array
for count = lbound(vArrayItem) to ubound(vArrayItem)
'See if it is a replacement variable and exists in the dictionary
if left(vArrayItem(count),6) = "tkRep_" and
p_ReplaceVars.exists(vArrayItem(count)) then
' then replace it
Error occurs here >> vArrayItem(count) =
p_ReplaceVars.Item(cstr(vArrayItem(count)))
end if
next
dim vArrayItemNew
vArrayItemNew = ""
' Loop through the array and put it back together
for count = lbound(vArrayItem) to ubound(vArrayItem)
if vArrayItem(count) = ubound(vArrayItem) then
vArrayItemNew = vArrayItemNew & vArrayItem(count)
else
vArrayItemNew = vArrayItemNew & vArrayItem(count) & " "
end if
next
' return the vArrayItemNew to the function
ReplaceVars = vArrayItemNew
End Function
The error message I get is:
ADODB.Field (0x800A0D5C)
Object is no longer valid.
D:\WWW\LCDEV\DOC_FUNCTIONS\../classes/classlcDocTKit_item.asp, line 52
However I have no idea why, it is a dictionary object and not a
recordset, the object should still be open.
Any help is greatly appreciated.
Thanks