Solved

Error Code insertion.....

Posted on 2000-05-18
2
131 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
2 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now