Solved

Error Code insertion.....

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

688 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