Re: Type mismatch calling a COM object developed in vb6
- From: wolfing1@xxxxxxxxx
- Date: 15 Feb 2006 11:28:09 -0800
Dag Sunde wrote:
<wolfing1@xxxxxxxxx> wrote in messageThanks all for your posts, it's a lot of info I didn't know, never
news:1140017091.779500.182890@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dag Sunde wrote:
<spkelly@xxxxxxxxxxxxx> wrote in messageThanks all for your responses. I changed the function declaration to
news:1139947917.518866.101060@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Michael B. Johnson wrote:As I have posted earlier in this thread...
On Mon, 13 Feb 2006 19:46:49 GMT, "Veign" <NOSPAMveign1@xxxxxxxxx>
wrote:
Did you try:
response.write obj.test(cstr(k))
Chris is right: the OP's problem is that he needs to cast the variant
in
the ASP
page to the string type expected by the VB procedure.
Couldn't he also just change the dim statement to
dim k as string
cstr(x) is probably safer...
just curious
If you want to call a method in a VB Com component from
an .ASP page, all the parameters for that method *must*
be declared By Value in the component:
public function test( ByVal a as string)
... ^^^^^
end function
--
be all variants and it works.
But what you said above is boggling. Do you mean I can't pass
parameters to .COM objects by reference? In another COM object I'm
writing right now (haven't tested yet), I was passing parameters
(byref) that were going to be filled out by the COM object, do you mean
I can't do that? How would I do that if all parameters must be passed
Byval?
Declare a class with all the public properties you'll need,
and use an instance of that class as a returnvalue from
your function...
Public class CUser
Public Name as string
Public Phone as string
Public Age as long
...
In your function:
Public function getUser(byVal userId as long) as CUser
....
' get all userdata...
getDataFromId(userId)
Dim oUser as CUser
Det oUser = New CUser
oUser.Name = blablaName
oUser.Phone = blablaPhone
oUser.Age = BalAge
Set getUser = oUser
End Function
In .Asp
Dim o
Set o = Server.CreateObject("Comp.Class")
Dim oUser
Set oUser = o.getUser(12)
Response.Write oUser.Name
Response.Write oUser.Phone
Response.Write oUser.Age
...
(...Or something like that...)
--
Dag.
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
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
How can I access the fields inside the resulting array?
.
- Follow-Ups:
- Re: Type mismatch calling a COM object developed in vb6
- From: Dag Sunde
- Re: Type mismatch calling a COM object developed in vb6
- References:
- Type mismatch calling a COM object developed in vb6
- From: wolfing1
- Re: Type mismatch calling a COM object developed in vb6
- From: Veign
- Re: Type mismatch calling a COM object developed in vb6
- From: Michael B . Johnson
- Re: Type mismatch calling a COM object developed in vb6
- From: spkelly
- Re: Type mismatch calling a COM object developed in vb6
- From: Dag Sunde
- Re: Type mismatch calling a COM object developed in vb6
- From: wolfing1
- Re: Type mismatch calling a COM object developed in vb6
- From: Dag Sunde
- Type mismatch calling a COM object developed in vb6
- Prev by Date: Re: Get Text length not using hdc or any control
- Next by Date: TreeView and checkboxes
- Previous by thread: Re: Type mismatch calling a COM object developed in vb6
- Next by thread: Re: Type mismatch calling a COM object developed in vb6
- Index(es):
Relevant Pages
|