PicoHRDL.dll problems with Excel VBA

Post your VB and VBA discussions here
Post Reply
RobNewbury
User
User
Posts: 2
Joined: Sat Jul 26, 2008 4:17 pm
Location: South West UK

PicoHRDL.dll problems with Excel VBA

Post by RobNewbury »

I am having problems with VBA code that uses the PicoHRDL.dll in conjunction with ADC-20 logger.

The Excel application crashes either while the VBA is running or a little while after.

This happens even with the supplied example spread sheet HRDL.XLS. I have tried on three different computers (but with same ADC-20) and get the problem with them all.

Can't tie the crash down to a particular line of code in the VBA, it seems that once the call to HRDLRun(handle, 100, 0) has been made the crash could occure at any time. Sometimes the VBA program will complete and update the spread sheet but still get the "program not responding" message when Excel is exited. When this happens re-running Excel and loading the HRDL.XLS spread sheet gives the spread sheet locked for editing as already in use (by me!!) error. If the ADC-20 is unplugged and re-plugged from the USB port before re-loading HRDL.XLS, then the spread sheet is not locked for editing.

RobNewbury
User
User
Posts: 2
Joined: Sat Jul 26, 2008 4:17 pm
Location: South West UK

PicoHRDL.dll problems with Excel VBA

Post by RobNewbury »

Having done some more work on this, with regard to the example macro in HRDL.XLS, it turns out that the problem comes at the call to HRDLGetTimesAndValues(handle, times(0), values(0), 0, 100).
There are some problems with this call, firstly the fourth paramater should be a pointer to Overflow of type single, whereas it is called as a variable of type single. Also on closer inspection I found that the decleration for this function is wrong and is defined as Declare Function HRDLGetTimesAndValues Lib "C:\EDisc\examples\Excel\HRDL\PicoHRDL.dll" (ByVal handle As Integer, times As Long, values As Long, ByRef overflow As Integer, ByVal noOfValues As Long) As Long, both the variables times and values should be pointers, so the decleration should read:-
Declare Function HRDLGetTimesAndValues Lib "C:\EDisc\examples\Excel\HRDL\PicoHRDL.dll" (ByVal handle As Integer, ByRef times As Long, ByRef values As Long, ByRef overflow As Integer, ByVal noOfValues As Long) As Long

Some of these issues could explain why Excel crashes after the call as some memory locations that should be pointers will be screwed up.

... Even so having made these corrections to the example macro HRDL.XLS, the Excel application will still crash at some point after the call to HRDLGetTimesAndValues has been made.
I have found that replacing HRDLGetTimesAndValues with a call to HRDLGetValues does not cause Excel to crash.

.. Some assistance with this would be appreciated.

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Post by ziko »

Hi I have managed to recreate your problem. I have reported this as a bug report.

Kind regards
Ziko

Technical Specialist

Post Reply