Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Visual basic simple error checking question On error

Posted on 2004-08-28
4
Medium Priority
?
241 Views
Last Modified: 2010-04-17
How do I reset the on error statement?  Example:

on error goto ErrOccured
msgbox "hello world"

'starting here I don't want errors to goto ErrOccured and I may not have any further error checking in place so undesired effects could occur if things went to ErrOccured

BTW is there a way to goto an error trap and then back to your code without goto statements?
0
Comment
Question by:bluedragon99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Author Comment

by:bluedragon99
ID: 11922029
what would be a good way to error check this for example:

Open OptionsFrm.LoggingPath.Text For Append As #2
       Print #2, "Test"
Close #2
0
 
LVL 22

Accepted Solution

by:
cookre earned 1000 total points
ID: 11922173
To disable error handling:

on error goto 0


For the example:

on error goto oops
Open OptionsFrm.LoggingPath.Text For Append As #2
on error goto 0
Print #2, "Test"
Close #2



0
 
LVL 3

Assisted Solution

by:Stimphy
Stimphy earned 1000 total points
ID: 11923691
Try This...

Private sub ErrorExample()
On Error Goto ErrHand
    msgbox "hello world"
On Error Resume Next 'Program execution will continue ignoring all errors... use sparingly or line by line
   msgbox "hello world"
   If Err.Number > 0 Then
       'An Error Occured
   End If
On Error Goto 0  'Disables Error Handling as stated by cookre... but your program execution will stop
   MsgBox "hello world"
Exit sub
ErrHand:
   Msgbox Err.Number & " " & err.Description
   Resume Next 'Causes the next line after the error to be executed
   Resume        'Causes the line that caused the error to be re-executed.
End Sub

Regaurds,
Dave
0
 
LVL 5

Expert Comment

by:WesleySaysHi
ID: 11923997
Use:

   on error goto ErrOccured

to jump to ErrOccured when there is an error.

Use:

   on error Resume Next

to jump to the next line of code without going to ErrOccured.

This is the most simple way.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Make the most of your online learning experience.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question