I am using a parallel port ADC10 to capture data directly into an Excel 2000 workbook. I am using the sample function (which calls the ADC1032.dll file) contained in the Excel workbook previously emailed to me by tech support.
My problem is that although the code works fine on a first pass, if I attempt to execute the code again I get a result saying 'Unable to open ADC'. An examination of the adc10_get_unit_info output returns a string of 'Pico.sys not found'. How do I close the ADC and then reopen it? If I close the workbook and then reopen it, this works, but I would rather do this through code. I have tried calling both the adc10_set_unit and adc10_close_unit statements, but they seem to have no effect. Any guidance & advice greatly appreciated!
Incidentally, I am using Excel 2000 (SP3) on a notebook running Windows XP (SP2).
Code: Select all
Option Explicit Declare Function adc10_get_driver_version Lib "ADC1032.DLL" () As Integer Declare Function adc10_open_unit Lib "ADC1032.DLL" (ByVal port As Integer, ByVal product As Integer) As Integer Declare Function adc10_set_unit Lib "ADC1032.DLL" (ByVal port As Integer) As Integer Declare Sub adc10_close_unit Lib "ADC1032.DLL" (ByVal port As Integer) Declare Function adc10_get_unit_info Lib "ADC1032.DLL" (ByVal S As String, ByVal lth As Integer, ByVal line_no As Integer, ByVal port As Integer) As Integer Declare Function adc10_get_value Lib "ADC1032.DLL" () As Integer Declare Sub adc10_set_trigger Lib "ADC1032.DLL" (ByVal enabled As Integer, ByVal enable_auto As Integer, ByVal auto_ms As Integer, ByVal rising As Integer, ByVal threshold As Integer, ByVal delay As Integer) Declare Function adc10_set_interval Lib "ADC1032.DLL" (ByVal us_for_block As Long, ByVal ideal_no_of_samples As Long) As Long Declare Function adc10_get_values Lib "ADC1032.DLL" (values As Integer, ByVal no_of_values As Long) As Long Declare Function adc10_get_times_and_values Lib "ADC1032.DLL" (times As Long, values As Integer, ByVal no_of_values As Long) As Long Dim times(6000) As Long Dim values(6000) As Integer Dim S As String * 255 Dim i As Integer Dim j As Integer Public port As Integer Public product As Integer Public opened As Boolean