Re: Type mismatch calling a COM object developed in vb6



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

Dag Sunde wrote:
<spkelly@xxxxxxxxxxxxx> wrote in message
news:1139947917.518866.101060@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Michael B. Johnson wrote:
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

As I have posted earlier in this thread...

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

--
Thanks all for your responses. I changed the function declaration to
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.


.



Relevant Pages

  • Re: Hiding ASP source code
    ... Set objRS = cmd.Execute ... Dim sqlString As String ... Dim objConn As ADODB.Connection ... Call the object from ASP ...
    (microsoft.public.inetserver.asp.general)
  • ASP Prob: Invalid procedure call or argument:
    ... I'm having a small problem calling my .net component from ASP which I'm ... dim obsession ... public string Create(Responses.ISessionInfo session, string mapName, string ...
    (microsoft.public.dotnet.framework.interop)
  • Re: HTML in Plain Text umwandeln
    ... Dim result As String = Regex.Replace ... Falls Du einen anderen oder einen mächtigeren Regex brauchst, ... German ASP / ASP.NET-Portal: http://www.aspextra.de ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • Re: cant run classic asp code in header of aspx file
    ... you can refer to the asp file seperately. ... > Sub Page_Load ... Dim strConn as string ... Dim strSQL as string ="select events from EventTable" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: cant run classic asp code in header of aspx file
    ... you can refer to the asp file seperately. ... > Sub Page_Load ... Dim strConn as string ... Dim strSQL as string ="select events from EventTable" ...
    (microsoft.public.dotnet.general)