There are two ways to use COM libraries;  Early binding and Late binding.


Early Binding:

Early binding is the preferred way to work with COM objects.  Besides somewhat better performance, the fact that it provides you with Intellisense is probably the most important.


In order for your application to make use of early binding, you need to reference by selecting it from the menu in your IDE:


VB6:                                  [Project][References]

VBA (Office):                  [Tools][References]

.NET: (Visual Studio)        [Project][Add Reference][COM][Type Library]



 



Here we have declared the public reference to the MatLab Toolkit Library as 'Lib'.  

You can use any object name you wish but this document will use 'Lib' throughout.


       


You will want to define this typically in a global type module that can be referenced from anywhere in your application and so that you do not unintentionally create multiple instances.


Late Binding:

Late binding is an alternative way to work with COM objects.


 


Next Steps:

The first thing you must do before you call any function of the library is connect it to MatLab.

The library will automatically connect to MatLab if you omit this but it is better to connect to it explicitly to control the connection.