Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error Trapping Help !

Posted on 2003-03-21
1
Medium Priority
?
136 Views
Last Modified: 2010-05-01
let's say i want to read a file content from a:\test1.txt . If the floppy disk is not inserted ,or it cannot read the file or whatever run-time error , how can i display a msgbox "error!" rather than those Run-time error msg ?
0
Comment
Question by:ANGWK
1 Comment
 
LVL 43

Accepted Solution

by:
TimCottee earned 60 total points
ID: 8180069
Hi ANGWK,

On Error Goto errHandler

'Here is your code for reading the file:

Exit Sub

errHandler:
  Select Case err.Number
  Case 52
    Msgbox "File Not Found"
  Case 75
    Msgbox "Access Denied"
  Case Else
    Msgbox "Some other error occured"
  End Select
  Resume Next 'Allows you to resume processing at the next statement
Exit Sub

This is basic error handling process and should be implemented in every function/sub that requires it.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

578 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