Ok I'm struggling with the whole "type mismatch" fiasco that everyone seems to run into when dealing with byref parameters using ASP to call a VB6 COM Object. Microsoft has detailed the problem here: http://support.microsoft.com/kb/244012/EN-US/ and there is a supposed workaround here: http://www.15seconds.com/issue/010525.htm
I'm trying the workaround because I have a current project that is passing parameters for the COM object to change, but the parameters have to be returned as arrays. I'm not exactly sure how that works. Here's what I'm trying to do- Since in order for me to use byref when passing parameters to my COM object, i'm going with what the 15sec article says and passing it in as a variant data type with the intention of making the modifications to an internal strong type object (or array in this case) and then copying it back to the parameter for use outside the object again.
I know this is confusing but it really does follow what the article is tryign to say. I just can't freaking get it to work with an array.
VBScript/ASP:
Function ChangeData(Param1, Param2, Param3)
set Obj=Server.CreateObject("MyDLL.Class1")
status = Obj.Query(Param1, Param2, Param3)
set Obj = nothing
dim NewData
NewData = Ubound(Param1, 2) 'param1 is supposed to be an array here (through COM manipulation)
End Function
VB6 Code:
Public Function Class1(Param1 as Variant, Param2 as Variant, Param3 as Variant)
dim internalParam1(0,0)
internalParam1() = Param1 'throws error here-- i'm trying to set the local variable to the parameter
...
(code throws data into local array from recordset)
...
Param1 = internalParam1() 'pseudocode: setting array back to parameter
End Function
Narrative: So I call the VBScript function, pass it 3 parameters, which it then uses to pass to the COM object. The VB6 object takes the 3 variant parameters, assigns them to local arrays (in the article it uses recordsets as an example), fills the arrays, and then sets the parameters back so that the ASP function can continue. The ASP function then does the ubound on the array and in theory, extracts the necessary data. I just can't figure out how to get VB6 to assign a local array to a variant type.
Any ideas?
I'm trying the workaround because I have a current project that is passing parameters for the COM object to change, but the parameters have to be returned as arrays. I'm not exactly sure how that works. Here's what I'm trying to do- Since in order for me to use byref when passing parameters to my COM object, i'm going with what the 15sec article says and passing it in as a variant data type with the intention of making the modifications to an internal strong type object (or array in this case) and then copying it back to the parameter for use outside the object again.
I know this is confusing but it really does follow what the article is tryign to say. I just can't freaking get it to work with an array.
VBScript/ASP:
Function ChangeData(Param1, Param2, Param3)
set Obj=Server.CreateObject("MyDLL.Class1")
status = Obj.Query(Param1, Param2, Param3)
set Obj = nothing
dim NewData
NewData = Ubound(Param1, 2) 'param1 is supposed to be an array here (through COM manipulation)
End Function
VB6 Code:
Public Function Class1(Param1 as Variant, Param2 as Variant, Param3 as Variant)
dim internalParam1(0,0)
internalParam1() = Param1 'throws error here-- i'm trying to set the local variable to the parameter
...
(code throws data into local array from recordset)
...
Param1 = internalParam1() 'pseudocode: setting array back to parameter
End Function
Narrative: So I call the VBScript function, pass it 3 parameters, which it then uses to pass to the COM object. The VB6 object takes the 3 variant parameters, assigns them to local arrays (in the article it uses recordsets as an example), fills the arrays, and then sets the parameters back so that the ASP function can continue. The ASP function then does the ubound on the array and in theory, extracts the necessary data. I just can't figure out how to get VB6 to assign a local array to a variant type.
Any ideas?