Re: Type mismatch calling a COM object developed in vb6



<wolfing1@xxxxxxxxx> wrote in message
news:1140031689.354465.103810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Dag Sunde wrote:
<snipped />
Thanks all for your posts, it's a lot of info I didn't know, never
programmed COM objects before, specially not ones to be used by ASP.
Now if you can check on this situation that is giving me problems
(going to change the 'As Variant' for a byval with the real type later,
but I don't think that's the problem):
[COM Object]
public class ProdOrd
Public prodcode As String
Public qty As Single
...
end class

Now how do I pass an array of ProdOrd to a function in the COM object?:
Public Function checkav(session As Variant, requestlist As Variant,
Optional shipstate As Variant = "") As ProdOrd()
dim arrResult(1) as ProdOrd
set arrResult(0) as new prodord
set arrResult(1) as new prodord
arrResult(0).prodcode = "a"
arrResult(1).prodcode = "b"
checkav = arrResult
end function


You have to SET the function result above (Always SET when
assigning an object of any kind...
...
Set checkav = arrResult
end function

See if that helps on the result in your .ASP script.


And in ASP the following call gives me a type mismatch error:
dim r
dim o
dim pr(1)
set o = server.createobject("products.product")
set pr(0).prodcode = "x"
set pr(1).prodcode = "y"
r = o.checkav("1",pr, "NY") 'This line runs fine
response.write ubound(r) 'This returns 1, so far so good
response.write r(0).prodcode 'ERROR: Type mismatch


I'll come back to you concerning how to pass Objects IN to the function

--
Dag.


.



Relevant Pages

  • Re: Type mismatch calling a COM object developed in vb6
    ... the OP's problem is that he needs to cast the variant ... Couldn't he also just change the dim statement to ... an .ASP page, all the parameters for that method *must* ... Now how do I pass an array of ProdOrd to a function in the COM object?: ...
    (comp.lang.basic.visual.misc)
  • Re: My COM always writes two same data in the system
    ... classic ASP way but going through a vb6.0-based Active X DLL file. ... However it always adds two identical records at the same time. ... Public Function AddNotes(SID As Variant, RID As Variant, Topic As ... Dim conn As ADODB.Connection ...
    (microsoft.public.inetserver.asp.components)
  • Re: Type mismatch calling a COM object developed in vb6
    ... Now how do I pass an array of ProdOrd to a function in the COM object?: ... Public Function checkav(session As Variant, requestlist As Variant, ... dim arrResultas ProdOrd ...
    (comp.lang.basic.visual.misc)