Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxGetSysDevNames in VB6.0

I am using VB 6.0
 
See sample code below
 
Private Sub Command1_Click()
Dim MyName As String
Dim MyString As String
DAQmxErrChk DAQmxGetSysDevNames(MyName, 256)
DAQmxErrChk DAQmxGetDevProductType("Dev2", MyString, 256)
End Sub
 
Using the above code with a USB-6501 connected, Both MyName and MyString return empty (MyName = "",  MyString = "")
 
I know thw device is Dev2 since that is the device I use in the rest of the program that allows me to read and write data.  I am just trying to programaticaly determain the devices connected sinc this is a test system with sveral NI USB devices
 
I am able to get   DAQmxGetDevSerialNum  to return the correct Serial number for  "Dev2"
 
 
0 Kudos
Message 1 of 4
(4,126 Views)
Hi CUImsch,

Thank you for posting on the National Instruments forums.

I am seeing the same issue that you are seeing.  Can you let me know what version of DAQmx you are using?  You can find this by going to the Measurement and Automation Explorer, expanding the Software, highlighting NI-DAQmx and looking on the right side for the version.

I am seeing this behavior in NI-DAQmx 8.6.
Thank You,

Nick F.
Applications Engineer
0 Kudos
Message 2 of 4
(4,112 Views)
Hi CUImsch,

The issue that you are seeing is because the string is not initialized to a certain length before it is returned.  Basically, the function that you are calling returns a pointer to a string but doesn't return the length of the string.  If you use this code when you define your variables, you will see the correct values returned.

Dim MyName As String * 50
Dim MyString As String * 10

Where 50 and 10 are the lengths of MyName and MyString respectively.  You will need to make sure to define the variable to be larger than the expected return value.  If the return value is smaller than your defined variable the remaining characters in the strings will be a square character. 
Thank You,

Nick F.
Applications Engineer
Message 3 of 4
(4,097 Views)
Thanks that worked fine
0 Kudos
Message 4 of 4
(4,092 Views)