Test and Measurement Forum

Can't get the UsbDrDaqGetSingle function to work in VBA

Post your VB and VBA discussions here

Can't get the UsbDrDaqGetSingle function to work in VBA

Postby guywags » Thu Aug 30, 2012 9:05 pm

I am writing an Excel 2007 VBA program that calls the UsbDrDaqGetSingle function to get a single reading from the DrDAQ module. I returns error code 10 hex when I assign channel number 3 to the channel variable. If I put a 3 directly in the function call, VBA and Excel terminate due to a severe error. I have the function declared as follows:
Code: Select all
Public Declare Function UsbDrDaqGetSingle Lib "USBDrDAQ.dll" (ByVal handle As Integer, ByVal channel As Integer, ByVal value As Integer, ByVal overflow As Integer) As Long


The Pico programming document indicates that the type for the channel argument is supposed to be defined as: USB_DRDAQ_INPUTS. I am not sure how to handle this in VBA. I have tried all the known types without any luck. Any suggestions on how to make this function work in VBA?
guywags
Newbie
 
Posts: 0
Joined: Thu Aug 30, 2012 4:15 am

Re: Can't get the UsbDrDaqGetSingle function to work in VBA

Postby Martyn » Fri Aug 31, 2012 10:49 am

Can you try

Code: Select all
Public Declare Function UsbDrDaqGetSingle Lib "USBDrDAQ.dll" (ByVal handle As Integer, ByVal channel As Long, ByRef value As Integer, ByRef overflow As Integer) As Long
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 1 guest