Results 1 to 16 of 16

Thread: Matlab function in VB.NET does not work. What's wrong with it?

Threaded View

  1. #14

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    9

    Re: Matlab function in VB.NET does not work. What's wrong with it?

    Quote Originally Posted by techgnome View Post
    there's nothing wrong with the com object... at least there wouldn't be if you actually instanciated it... you declared calcul as a tesxting_COM.Class1 ... that's fine... but you never created the instance...

    Code:
    Imports testing_COM
    
    Public Class Form1
    
    Dim calcul As testing_COM.Class1
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      calcul = new testing_COM.Class1 ' <-- THIS is what you forgot to do
      Dim result As Object = New Object()
      calcul.test(1, result, 16) '<-- had you checked here, you would have seen that "calcul" was nothing and thus the source of the error.
    
    End Sub
    
    End Class
    -tg

    Also error: "COMException was unhandled: Undefined function or method 'sqrt' for input arguments of type 'int32'.
    Error in => test.m at line 2"

    Function in Matlab (test.m):

    function t = test(n)
    t=sqrt(n);
    end
    Last edited by Reprod; May 13th, 2013 at 02:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width