Discussion:
DAQmxGetSysDevNames in VB6.0
(too old to reply)
CUlmsch
2007-09-03 18:40:10 UTC
Permalink
I am using VB 6.0
 
See sample code below
 
Private Sub Command1_Click()Dim MyName As StringDim 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"
 
 
Nick F
2007-09-05 18:10:11 UTC
Permalink
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 * 50Dim 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. 

Loading...