Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a c++ COM dll which i am trying to access through the vbscript. The Object is created just fine but always shows the error "type mismatch: function name"
VB SCRIPT CODE-
VB
d dim obj1
	set obj1=CreateObject("Begineers.first")
   Dim lngReturnValue 
   Dim a
   a=5
    Dim b
	b=7
    obj1.AddNumbers a, b, lngReturnValue

    Wscript.Echo( "The value of a+b is: " & lngReturnValue)

    Set obj1 = Nothing


Functions in c++ dll -
C#
STDMETHODIMP Cfirst::AddNumbers(LONG Num1, LONG Num2, LONG* ReturnVal)
{
    // TODO: Add your implementation code here
 *ReturnVal = Num1 + Num2;
    return S_OK;
}
Posted
Comments
Patrice T 11-Aug-15 1:28am    
What is your question ?
What id the problem ? Where ?
Somesh Dhal 11-Aug-15 5:49am    
when i compile the function it is reporting an error showing "Type mismatch in function"
KarstenK 11-Aug-15 8:38am    
The error is correct. You must correct your call of AddNumbers. But I got no clue how :-O
F-ES Sitecore 11-Aug-15 11:20am    
If your function returns a value it needs parenthesis around the params. Not sure if that's your problem though; obj1.AddNumbers (a, b, lngReturnValue). You might also have issues with the "by ref" lngReturnValue. Try a simpler method call with basic input\output params to eliminate it being something specific to your method signature.

1 solution

One possibility...
VB (script) might be complaining about the type LONG* for an out/retval
You don't show your idl, so I can't see how the method is declared
But it might be worth using a variant for the result, e.g.

[out, retval] VARIANT* retval
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900