Go Back   Trackpads Community > General Discussions > Computer and Technology > Microsoft Applications

Microsoft Applications Discussions about Windows and other MS Products such as Office

Reply
 
LinkBack Thread Tools
Old 02-16-2005, 08:00   #1 (permalink)
=?gb2312?B?Q2FjdHVzIFvPycjLx/Jd?=
Civilians

 
Default Handle Error.

A procedure often Number Overflow.
So I put this handler in procedure.


Private Sub Hint()

On Error GoTo Overflow
....... ' Some codes.
Exit Sub

Overflow:
If (Err = 6) Then
......' Handling error.
End If

End Sub


but if other Error happen.
it could be a unhandle error.
because I not handing all err number.

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 02-16-2005, 08:00   #2 (permalink)
Harald Staff
Civilians

 
Default Re: Handle Error.

Hi

I suggest a Select Case structure on err number, like this:

Sub test()
Dim i As Long

On Error GoTo ErrHandler

i = 23232323232323# ^ 2
MsgBox "i=" & i

i = 23 / 0
MsgBox "i=" & i

Exit Sub

ErrHandler:
Select Case Err.Number
Case 6
MsgBox "Overflow"
i = 500
Resume Next
Case 11
MsgBox "Div 0"
i = 0
Resume Next
Case Else
MsgBox Error, Err.Number
End Select
End Sub

You may find a list of errors useful when you work on this. Run this on a
blank worksheet:

Sub ErrorList()
Dim L As Long
Dim R As Long
On Error Resume Next
For L = 1 To 1000
Err.Raise L
If Error <> "Application-defined or object-defined error" Then
R = R + 1
Cells(R, 1).Value = Err.Number
Cells(R, 2).Value = Error
End If
Err.Clear
Next
End Sub


HTH. Best wishes Harald



"Cactus [ΟΙΘΛΗς]" <a@b.com> skrev i melding
news:u1OvdNAFFHA.3416@TK2MSFTNGP09.phx.gbl...
> A procedure often Number Overflow.
> So I put this handler in procedure.
>
>
> Private Sub Hint()
>
> On Error GoTo Overflow
> ...... ' Some codes.
> Exit Sub
>
> Overflow:
> If (Err = 6) Then
> .....' Handling error.
> End If
>
> End Sub
>
>
> but if other Error happen.
> it could be a unhandle error.
> because I not handing all err number.
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2005, 08:00   #3 (permalink)
=?gb2312?B?Q2FjdHVzIFvPycjLx/Jd?=
Civilians

 
Default Re: Handle Error.


Harald


Well, that Err Number List is great.
Can I using this way?
Throws Err to default handler.


Overflow:
If (Err = 6) Then
.....' Handling error.
Else
Err.Raise Err
End If







> Hi
>
> I suggest a Select Case structure on err number, like this:
>
> Sub test()
> Dim i As Long
>
> On Error GoTo ErrHandler
>
> i = 23232323232323# ^ 2
> MsgBox "i=" & i
>
> i = 23 / 0
> MsgBox "i=" & i
>
> Exit Sub
>
> ErrHandler:
> Select Case Err.Number
> Case 6
> MsgBox "Overflow"
> i = 500
> Resume Next
> Case 11
> MsgBox "Div 0"
> i = 0
> Resume Next
> Case Else
> MsgBox Error, Err.Number
> End Select
> End Sub
>
> You may find a list of errors useful when you work on this. Run this on a
> blank worksheet:
>
> Sub ErrorList()
> Dim L As Long
> Dim R As Long
> On Error Resume Next
> For L = 1 To 1000
> Err.Raise L
> If Error <> "Application-defined or object-defined error" Then
> R = R + 1
> Cells(R, 1).Value = Err.Number
> Cells(R, 2).Value = Error
> End If
> Err.Clear
> Next
> End Sub
>
>
> HTH. Best wishes Harald
>
>
>
> "Cactus [ΟΙΘΛΗς]" <a@b.com> skrev i melding
> news:u1OvdNAFFHA.3416@TK2MSFTNGP09.phx.gbl...
> > A procedure often Number Overflow.
> > So I put this handler in procedure.
> >
> >
> > Private Sub Hint()
> >
> > On Error GoTo Overflow
> > ...... ' Some codes.
> > Exit Sub
> >
> > Overflow:
> > If (Err = 6) Then
> > .....' Handling error.
> > End If
> >
> > End Sub
> >
> >
> > but if other Error happen.
> > it could be a unhandle error.
> > because I not handing all err number.
> >

>
>


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
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
ROM Upgradation problems with iPAQ 3835 - Error: 101 & Error 113 Kaustubh Nirmal Microsoft Applications 1 07-23-2004 20:55
ROM Upgradation problems with iPAQ 3835 - Error: 101 & Error 113 Kaustubh Nirmal Microsoft Applications 1 07-23-2004 20:42
ROM Upgradation problems with iPAQ 3835 - Error: 101 & Error 113 Kaustubh Nirmal Microsoft Applications 1 07-23-2004 20:25
Error - Compile Error in Hidden Module: AutoExec Big Rhino Microsoft Applications 1 06-16-2004 20:40
What would you do/How would you handle this? Betty Boop Chit-Chat 40 04-22-2004 09:56


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 13:07.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.67355 seconds with 19 queries