Solved

Wrong number of arguments or invalid property assignment error when calling Matlab Com in Visual Basic

Posted on 2003-11-25
5
3,734 Views
Last Modified: 2013-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)
   c= 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
 Dim obj_dll
 Set obj_dll = CreateObject("sumtwolib.sumtwoclass")
 sum = obj_dll.sumtwo(1, 2)
 MsgBox sum
End Sub

Could someone kindly help me. Dll and Com are new for me.

Thanks in advance
0
Comment
Question by:yangye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9819732
what is the return value of summtwo procedure?
Implemented code for that function?
0
 

Author Comment

by:yangye
ID: 9821355
I have figured out this problem by myself. Where Matlab's Dll function is a little different from others. I did like this:

......
obj_dll.sumtwo(1, sum, 1.0, 2.0)
......

where 1 means only 1 output parameter, sum is the output parameter, 1.0 and 2.0 are two input parameters, respectively. It also shown that this didn't work on integer input parameter. I don't know why, so I just changed them to double.
0
 

Author Comment

by:yangye
ID: 9821366
Thanks Richie_Simonetti for your kind reply. The return value of sumtwo function is the sum of the two input parameters. I have figured out how to do it. See my previous comment.
0
 
LVL 11

Accepted Solution

by:
bingie earned 20 total points
ID: 10080537
Question PAQed - 20 Points Refunded
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2005 text editor 10 54
How to hault or freeze parent form when a 2d form is open in vb6 3 46
VS2015 Redefinition errors 4 101
Input parameteres to DragOver 2 57
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question