?
Solved

Error Code insertion.....

Posted on 2000-05-18
2
Medium Priority
?
137 Views
Last Modified: 2010-05-02
In true Software Engineering style, I'm having to add error code after writing most of the source code! The app is in Excel (but can obviously be exported to VB files), and I need an addin / program which inserts error handling code into all functions and subs. In addition, it needs to be tailored to my own needs (in terms of the text it produces).

TA!
0
Comment
Question by:NikWhitfield
[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
2 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 200 total points
ID: 2820665
Nice one. The solution, I'm afraid, depends very much on the style in which you wrote your software. I can give you some suggestions though.

You can open any VB module file (this includes form, class and other modules) as a text file.

You can read through it

You can search for things like "Private", "Public" and "Friend" in combination with "Sub", "Function" and "Procedure", etc....

You can insert a line "On Error Goto ErrorHandler" after where a procedure starts

Search for corresponding "End <whatever>" statement

Insert some standard error handling.

ErrorHandler:
'Do something appropriate here


Nasty: Some Procedures can be written over several lines:

Private Sub ASubWithLotsOfParams(Param1 As String, _
                                 Param2 As String, _
                                 Param3 As String)

If you're not careful to deal with those line continuations, your handy error handling inserter will do this to that:

Private Sub ASubWithLotsOfParams(Param1 As String, _
On Error Goto ErrorHandler
                                 Param2 As String, _
                                 Param3 As String)



And this is just for starters. What if some of your procedures already contain a rudimentary error handler. Perhaps you'll have to scan your procedures and omit the addition of an error handler is any error handler is already present.

And so on and so forth.

I'm afraid you're going to have to do a lot of work yourself. There is no quick fix.
0
 
LVL 13

Expert Comment

by:crazyman
ID: 2820745
Taken from a PAQ.



From: ofirg
 Date: Monday, May 15 2000 - 02:53PM BST  
You can write your own Add_Procedure AddIn, that will insert "On Error"'s with a global error handling procedure  to every new sub\function you will add to your project.

I can help you with some code!
let me know if u want.
 

He offered to do it for someone else maybe hed do it for you.

personally i agree with caraf_g , its too much hassle and it is better to just grin and bear it and do in manually.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

800 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