LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Errors raised out of nowhere... help appreciated

Folks

I'm having a rather weird (to me at last) problem with error handling
in an Excel application. Here is the idea...

I have a class module with a few properties, say property aaa, bbb and
ccc, all accessed with property "get routines".

There is also a refresh method, where I actually load those properties
from an SQL server through ADO.

Every procedure has a specific error handler, which is systematically
invoked by an "on error goto myErrHdl" statement

Everything seems to be working fine except for the following sort
routine that sometimes (pretty often actually, but not always) fails in
a rather strange way...

<code

Public Sub MySuperSort (a() As myClass) ' --- a is an array of
myClass

Dim i As Integer, j As Integer
Dim Low As Integer, Hi As Integer
Dim PushPop As New myClass
Dim perfTimer As Date
Dim sortValue1 As Double, sortValue2 As Double


On Error GoTo errHdl

perfTimer = Now()

Low = LBound(a)
Hi = UBound(a)

If Hi = 0 Then Exit Sub

j = (Hi - Low + 1) \ 2

Do While j 0
For i = Low To Hi - j
sortValue1 = a(i).aaa ' <--- These are the
sortValue2 = a(i + j).aaa ' <--- offending statements
If sortValue1 < sortValue2 Then
Set PushPop = a(i)
Set a(i) = a(i + j)
Set a(i + j) = PushPop
End If
Next i
For i = Hi - j To Low Step -1
sortValue1 = a(i).aaa ' <--- These are the
sortValue2 = a(i + j).aaa ' <--- offending statements
If sortValue1 < sortValue2 Then
Set PushPop = a(i)
Set a(i) = a(i + j)
Set a(i + j) = PushPop
End If
Next i
j = j \ 2
Loop

Call addPerfEntry("SORT", CDbl(Now() - perfTimer) / Hi)

Exit Sub

' === ERROR HANDLER ===

errHdl:

' --- Setup error message
Dim errMsg As String
errMsg = "Error in proc [MySuperSort]: " & Err.Description
addLogEntry prmEntry:=errMsg, prmClass:="ERR" ' logs the message

' --- Warns the user
MsgBox errMsg

' --- Some more stuff here

</code


At some point (I can't really have it 100% replicated), this statement

sortValue1 = a(i).aaa

raises the following error *within* the sort proc (i.e it is not caught
in the property get, although there is an error handler).

Multiple-step OLE DB operation generated errors.
Check each OLE DB status value, if available. No work was done.

(btw the connectionObject.Errors.Count method returns 0)

Even stranger is that there is absolutely NO ADO activity whatsoever in
the properties. The whole code is a simple logical test (invoking one
other property) and a variable assignment from a private local variable
within the class module to the property:

Property Get aaa() As double

On Error GoTo errHdl

If me.bbb = 0 then

aaa = locAAAStorage

else

aaa = locAAAStorage

end if

exit property

errHdl:
stop

End Property


The local variable being initialized (correctly) by the refresh method.

This is really puzzling... All I can say is that the problem is not
machine dependent... and pretty annoying !
Any idea ?!

Thanks & regards

--alexT

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is is possible to do footnotes? (little raised number) gsued Excel Discussion (Misc queries) 2 May 1st 08 08:06 PM
How do i make a cell look embossed or raised in excel? Mr.Niceguy New Users to Excel 1 October 3rd 06 10:01 PM
Handling of event raised in other class module VbaNew Excel Programming 1 January 10th 05 12:42 PM
Event Raised by Paste Special + Link cduden Excel Programming 1 January 15th 04 06:50 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"