Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing The Names in the Data Neighborhood From Within Visual Basic

I would like to have my application get the names that are listed in the Measurement & Automation Data Neighborhood.
0 Kudos
Message 1 of 6
(4,188 Views)
There is not a function for this exposed in the ActiveX controls. I do have a utility DLL that should do it for you. There are two functions you will use in this DLL:


int GetNumberOfChannels(long* num);
int GetChannelNameByIndex(long index, char* nameBuffer, long* bufferSize);

The first fucntion returns the number of virtual channels and the second function retrieves the name and name length of a specific channel by index. They are written in C style so they can be used from any compiler.

If you have questions about this DLL, you can post them here.

Best Regards,

Chris Matthews
National Instruments
Download All
0 Kudos
Message 2 of 6
(4,188 Views)
Chris,
I downloaded the two files but VB won't let me reference the DLL. The files may have been damaged or I did something wrong. Is it possible for you to email me the files at davidbsmith@eaton.com.
Thanks
David Smith
Eaton Corporation
0 Kudos
Message 3 of 6
(4,188 Views)
As I said, this is just a C-style DLL. It doesn't have type information in it, so you can't add a reference to it. You have to call it like you would a Windows DLL. Put declarations at the top of the module like this:

Declare Function GetNumberOfChannels& Lib "scaleAccess.dll" (x1&)
Declare Function GetChannelNameByIndex& Lib "scaleAccess.dll" (ByVal x1&, ByVal x2$, x3&)

Then, you can call the functions. MSDN has some good information on calling DLL's in Visual Basic under Using Visual Basic->Accessing DLL's in VB

The below code is what I used to test these functions in VB. You would have to change the path to the DLL.

Private Declare Function GetNumberOfChannels Lib "c:\Projects\VB\scaleAccess.dll" _
(ByRef num As Long)
As Integer
Private Declare Function GetChannelNameByIndex Lib "c:\Projects\VB\scaleAccess.dll" _
(ByVal index As Long, ByVal ch As String, ByRef nameLength As Long) As Integer

Private Sub Command1_Click()
Dim num As Long
Dim channelName As String * 255
Dim nameLength As Long

Dim i As Long


GetNumberOfChannels num
For i = 0 To num - 1
nameLength = 255
GetChannelNameByIndex i, channelName, nameLength
channelName = Left(channelName, nameLength)
Next i

End Sub

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 6
(4,188 Views)
Chris,
Thanks for the return response on my question. The DLL works great and I can get the information I need. Does National have any information that I could use to create DLL's to access any additional information that measurement & automation holds (units, scales, ect.).
Dave Smith
0 Kudos
Message 5 of 6
(4,188 Views)
Not currently. We are working on creating an interface for customers into MAX in the future, but it isn't available yet. Until then, if you have specific needs that you can't find workarounds for, contact our support engineers and they may be able to find a solution for you.

Chris
0 Kudos
Message 6 of 6
(4,188 Views)