Solved

Error Code insertion.....

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 141
VB6 Compile Compatibility Issue 4 122
adding "ungroup sheets" to existing vbs code 5 57
Fastest way to find and count same items VB6 16 47
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

733 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