Wrong number of arguments or invalid property assignment error when calling Matlab Com in Visual Basic
Posted on 2003-11-25
I have a very simple mablab com (dll) function produced by matlab "comtool". The matlab .m file is named as sumtwo.m and looks like:
function c = sumtwo(a,b)
I used Matlab comtool to produce a com dll for it, and named it as sumtwolib.dll and assigned a classname of sumtwoclass to it. After I built it, I can see this dll in the visual basic object viewer. I want to call it in Visual basic and see whether it will work or not. I just used a button in my user form, and when I click that button, I want to see the result. But when I run it, I got an error of "run time error 450. Wrong number of arguments or invalid property assignment error". Below is the visual basic code I wrote.
Private Sub cmdSum_Click()
Dim sum As Integer
Set obj_dll = CreateObject("sumtwolib.sumtwoclass")
sum = obj_dll.sumtwo(1, 2)
Could someone kindly help me. Dll and Com are new for me.
Thanks in advance