Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

VB 6 DAQmxGetSysDevNames not working for usb-6008

I am trying to get the DAQmxGetSysDevNames to work using NI-DAQmx 8.3 and VB6 but the function is returning an empty string when trying against a USB-6008. The DAQmxGetDevProductType also returns an empty string. I can reset the device if I manually tell the software the device name with no issues. I can also get the Major and Minor of the the DAQ version. I have attached my code that I have been using to get this information in case anyone can see what I am doing wrong.
 
 
/Start code
 
    Dim DeviceFoundCheck As Boolean
    Dim DeviceNames As String
    Dim DeviceType As String
    Dim ErrorCode As Long
    Dim DeviceBuffer As Long
    Dim DAQMajorVersion As Long
    Dim DAQMinorVersion As Long
   
   
    'Device name is a Global String Variable
    DeviceName = "Dev1"
   
    'Get Device list
    ErrorCode = DAQmxGetSysDevNames(DeviceNames, DeviceBuffer)
   
    If ErrorCode < 0 Then
        MsgBox "Error detecting any DAQ devices"
        Exit Sub
    End If
   
    MsgBox DeviceNames
   
    'Get Type
    ErrorCode = DAQmxGetDevProductType(DeviceName, DeviceType, DeviceBuffer)
   
    If ErrorCode < 0 Then
        MsgBox "Error detecting DAQ device type"
        Exit Sub
    End If
   
    MsgBox DeviceType
   
    'Get DAQ version
    ErrorCode = DAQmxGetSysNIDAQMajorVersion(DAQMajorVersion)
    
     If ErrorCode < 0 Then
        MsgBox "Error detecting DAQ Major"
        Exit Sub
    End If
  
    ErrorCode = DAQmxGetSysNIDAQMinorVersion(DAQMinorVersion)
    
     If ErrorCode < 0 Then
        MsgBox "Error detecting DAQ Minor"
        Exit Sub
    End If
   
    MsgBox "You have DAQ version " & CStr(DAQMajorVersion) & "." & CStr(DAQMinorVersion)
    'Reset Device
    DeviceFoundCheck = ResetDevice(DeviceName)
   
    If DeviceFoundCheck = False Then
        MsgBox "USB Device not found, Please check status."
    End If
/End code 
 
Thanks,
 
Lee
0 Kudos
Message 1 of 3
(3,716 Views)

Hi Lee,

You just need to initialize your DeviceNames to something before passing it into the DAQmxGetSysDevNames function. I just added the following lines:

DeviceNames = "aaaaaaaaaaaaaaaaaaaaaaaa"
DeviceBuffer = 1000

and got a list of devices. This may not be the most elegant solution but it works 🙂

 

Abhinav T.
Applications Engineering
National Instruments India

LabVIEW Introduction Course - Six Hours
Getting Started with NI-DAQmx
Measurement Fundamentals
0 Kudos
Message 2 of 3
(3,696 Views)

Thanks,

That did work but I decided to do it this way for cleaner code.

    DeviceNames = String$(255, vbNullChar) ' Assign DeviceNames StrValue to 255 vbNullChars.
    DeviceBuffer = 1000

Then I added the next after the function call to clean out the unnecessary VBNullChar

    DeviceNames = Replace$(DeviceNames, vbNullChar, "")

0 Kudos
Message 3 of 3
(3,659 Views)