LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to define a class datatype from object library in labview 8?

Hello,
I will describe what i am doing in VisualBasic6. My request is for some explanation how to do the same thing in Labview.
  • I have project in VisualBasic 6 that some ObjectLibrary xxxOL.dll is marked in the reference list (not in component list).
  • xxxOL has 2 classes: yyyClass ,zzzClass
  • In VB6 code there is some line: "Dim yy As New yyyClass"
  • Now yy have some methods and properties...
My question is how to get this yy instance in labview.
 
tnx,
HaD
0 Kudos
Message 1 of 9
(3,999 Views)
If I understand what you want correctly, you need to compile your code into an ActiveX object and then use the ActiveX primitives to control it. If you search the example finder (Help>>Find Examples) for "ActiveX" you should find some examples.

___________________
Try to take over the world!
0 Kudos
Message 2 of 9
(3,991 Views)
I dont have code. I have a that DLL.
In VB its easy to create instance of Class from Object Library. (Dim xxx as New xClass)
My question is, how to create that instance in Labview.
Its not ActiveX, its just Class in Library .
 
I Hope that my terminology is fine 
 
tnx,
HaD
0 Kudos
Message 3 of 9
(3,989 Views)

If this is a .NET DLL, then you can use the .NET primitives.

If not, I really don't know. You can call exported functions from DLLs using the Call Library Function node, but I don't think it will give you what you want, because the only interfaces LV has for working with external classes are ActiveX and .NET. Since I don't know VB, I don't think I can help you any more.


___________________
Try to take over the world!
0 Kudos
Message 4 of 9
(3,983 Views)
Tnx for answer, but its not .Net or Activex...
0 Kudos
Message 5 of 9
(3,984 Views)
The Call Library Function Node in LabVIEW can only call functions, not directly instantiate class instances for code built into a DLL. If your DLL isn't an ActiveX DLL, then you will need to write or obtain a wrapper DLL that has functions you can call, such as a function that performs the operation Dim yy As New yyyClass and returns a reference that you can pass to some other function that acts on that class.

I've never worked with VB DLLs. But if VB can load the DLL and seemlessly instantiate a class instance embedded in it, it might actually be an ActiveX or .NET DLL, and you just don't know it. ActiveX and .NET DLLs contain the object-oriented hierarchy inside them and can be linked against just like any other code module you have. Regular DLLs only have lists of functions to call, regardless of which environment is loading and calling them. I don't see why VB would be any exception to this.

It might be worth your time to try to load this DLL as an ActiveX DLL and see what happens. It might have the appropriate type-library built into it, allowing LabVIEW to use Property Nodes and Invoke Nodes to traverse the object hierarchy, instantiate objects, and call object methods. If you have questions about how to test this, search help or examples, or post the questions to the forum.
Jarrod S.
National Instruments
0 Kudos
Message 6 of 9
(3,961 Views)
There's also an ActiveX object in Windows that executes VB scripts. Try googling it, or search the forums for examples. I don't know much about it but you could look into to it to see if you could simply execute a script directly in LabVIEW that will interface to your VB DLL. The only issues I can remember hearing about this is the inherint security issues involved with executing VB scripts and permissions and such.
Jarrod S.
National Instruments
0 Kudos
Message 7 of 9
(3,963 Views)

Hi HaD,

So the first thing to remember is that all Visual Basic DLLs are ActiveX DLLs and not Win32 DLLs. The Call Library Function node is only used for standard Windows DLLs (flat-based API) and not ActiveX DLLs (object-based API). 

Before I begin, there is an entire LabVIEW help topic entitled "Using ActiveX with LabVIEW" that is devoted to discussing how to use ActiveX objects, properties, methods and events with LabVIEW. It’s a great page.

To achieve what you want, you need to simply follow the steps in the "Calling an ActiveX Object from LabVIEW" help topic. Basically, you will drop down an automation refnum on your front panel and then right-click the refnum and select Select ActiveX Class. Then browse to your VB DLL and then make sure to select the "Show Creatable Objects Only" option. Now, based upon what classes you said your VB DLL has, you should see the yyyClass. Then in the dialog box, choose that yyyClass class. Switch to the block diagram and drop down an Automation Open function (from the ActiveX palette). Wire your reference into this Automation Open function which is needed to instantiate the yyyClass into an object. Then you can use Invoke Nodes and Property Nodes on this reference and access methods and properties. You essentially now have the yy object.

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
Message 8 of 9
(3,936 Views)

Thank you Jonathan N

It works!

0 Kudos
Message 9 of 9
(3,922 Views)