Solved

Error Code insertion.....

Posted on 2000-05-18
2
132 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 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