Can't get the UsbDrDaqGetSingle function to work in VBA

Post your VB and VBA discussions here
Post Reply
guywags
Newbie
Posts: 0
Joined: Thu Aug 30, 2012 4:15 am

Can't get the UsbDrDaqGetSingle function to work in VBA

Post by 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?

Martyn
Site Admin
Site Admin
Posts: 3309
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

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

Post by 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 Support Manager

Post Reply