Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

breakpoint changing the behavoir of my VBA code

  Asked By: Darryl    Date: Feb 19    Category: MS Office    Views: 816
  

I made an VBA (version 6) function (as part of excel 2000 version
9.0.6926 SP3 add-in). This functions calls an external function
(within a dll).
As the external function is quite complex I can't really go into
detail, and I hope that that is also not needed (also difficult to
debug this dll;-).

This is the function (and the declaration of the external one):

'###################################################################
Public Function HeliacalJDutSE2(JDNDaysUTStart, Age, SN, Lat,
Longitude, HeightEye, Temperature, Pressure, RH, VR, ObjectName,
TypeEvent, Optional AVkind)

Dim serr As String
Dim dret(20) As Double
serr = String(256, 0)
If IsMissing(AVkind) Then AVkind = "vr"
' for some reason Excel tries the function with a JDNDaysUTStart
undefined!
' that is why there is this if then statement
If JDNDaysUTStart = 0 Then
HeliacalJDutSE2 = "#VALUE!"
Exit Function
End If
'1
i = HeliacalJDutSEf(JDNDaysUTStart, Age, SN, Lat, Longitude,
HeightEye, Temperature, Pressure, RH, VR, ObjectName + String(1, 0),
TypeEvent, AVkind + String(1, 0), dret(0), serr)
'2
If i = 0 Then
'3
HeliacalJDutSE2 = dret(0)
'4
Else
'5
HeliacalJDutSE2 = "#NORISE!"
'6
End If
'7
End Function


Private Declare Function HeliacalJDutSEf Lib "swedll32.dll" _
Alias "_HeliacalJDut@96" ( _
ByVal JDNDaysUTStart As Double, _
ByVal Age As Double, _
ByVal SN As Long, _
ByVal Lat As Double, _
ByVal Longitude As Double, _
ByVal HeightEye As Double, _
ByVal Temperature As Double, _
ByVal Pressure As Double, _
ByVal RH As Double, _
ByVal VR As Double, _
ByVal ObjectName As String, _
ByVal TypeEvent As Long, _
ByVal AVkind As String, _
ByRef dret As Double, _
ByVal serr As String _
) As Long ' dret must be first of 20 array elements
' serr must be able to hold 256 bytes


If I put a VBA breakpoint at '1; I get no value after resuming the
program (somewhere an error?)
If I put a break point at '2 or '3; I get the correct value for after
resuming the program (dret(0) is also correct at the breakpoint). So I
know that a good result can be produced!
If I put a breakpoint at '4, '5, '6 or '7; the program never reaches
these lines (so it jumps out (?) of it, due to an error?)...
If I comment out the line under '1; the programs ends as expected.

Strange or not? Pehraps you have 'fresh' eye on this piece of code of
mine?

Do I make somewhere an obvious error in my own VBA code?
I find it strange a breakpoint can change the behavoir of the
functions, so I must do somethign wrong. It could be in the external
function, but I have no means of debugging that one...
Or does this breakpoiint behavoir point to some 'obvious' error in the
external function?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on breakpoint changing the behavoir of my VBA code Or get search suggestion and latest updates.




Tagged: