Re: Error Handlers for VB6
From: Ken Halter (Ken_Halter_at_Use_Sparingly_Hotmail.com)
Date: 03/23/05
- Next message: MikeD: "Re: Animated AVIs?"
- Previous message: Veign: "Re: Animated AVIs?"
- In reply to: dm4714: "Error Handlers for VB6"
- Next in thread: Larry Serflaten: "Re: Error Handlers for VB6"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Mar 2005 07:39:10 -0800
"dm4714" <spam@spam.net> wrote in message
news:eEs$uo7LFHA.436@TK2MSFTNGP09.phx.gbl...
>I have a VB6 application that updates a SQL Server database. The program
>works fine, but sometimes I receive SQL errors due to bad input or misisng
>information. I'm exeuting a bunch of SP that return various information.
>
> I have an Error Handler in my function and it is trapping for errors.
>
> My problem is, however, that I've changed my mouse pointer to an hour
> glass while the SQL queries are running. When I do get an error and the
> error handler is invoked, control is returned to my main form and the
> mouse pointer is still an hour glass.
Most of my apps do something like this.... when a user does something that
would take a while, Call EnableControls(False)... disables controls and sets
the mouse pointer. When it's done, error or not, Call
EnableControls(True)... enables controls and sets the mouse pointer.
'===============
Option Explicit
'this represents something a user would actually do (besides click on the
form <g>)
Private Sub Form_Click()
'fwiw, CodeSmart 2005 adds the error handling code with a single
keystroke (including the horizontal "lines")
Const ErrorLocation = "Form_Click"
On Error GoTo ErrorTrap
'==============================================================
Dim f As Single
'Disable the controls
Call EnableControls(False)
'do some work
f = Timer + 3 '3 seconds
Do While f > Timer
DoEvents
Loop
'==============================================================
Terminate:
'Enable the controls
Call EnableControls(True)
Exit Sub
ErrorTrap:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Debug.Assert False 'Stops here in the IDE
Resume Terminate
Resume 'In the IDE, jump here to find the line that raised the error.
End Sub
Private Sub EnableControls(State As Boolean)
Dim c As Control
Me.MousePointer = IIf(State, vbArrow, vbHourglass)
For Each c In Controls
c.Enabled = State
Next
DoEvents
End Sub
'===============
-- Ken Halter - MS-MVP-VB - http://www.vbsight.com Sign up now to help keep VB support alive - http://classicvb.org/petition Please keep all discussions in the groups..
- Next message: MikeD: "Re: Animated AVIs?"
- Previous message: Veign: "Re: Animated AVIs?"
- In reply to: dm4714: "Error Handlers for VB6"
- Next in thread: Larry Serflaten: "Re: Error Handlers for VB6"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|