Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Procedure is too large?

Status
Not open for further replies.

ixian

Programmer
Jul 13, 2001
128
US
Hi all,

I have a procedure that is too large?
a private sub form load is 600 lines... do i have to create a class module for it?If so how to connect it to the main form.

thanks
Aaron
 
Place the code you would like to execute in Load in another subroutine, either within the Form, or in a standard module and call it from Form_Load.
 
gumby

Since I will have more start up needs on this application just make them in a seperate class module and make them global.

thanks
Aaron
 
Hmmmmmmmmmmmmmmmmmmmmmmm,

600 lines of code is not "to large" from a program limit perspective. If you mean it is to large from a human factors or good programming practices perspective, then - Yes - you should 'break it up'. HOW you do this (e.g. what parts go where) is one of those "arts" or "beauty is in the eye of the beholder" issues. I generally prefer to keep as much code as possible in General Modules, reserving the modules associated with a specific form to the BARE mininum. Wheather the general modules are Classes or just plain modules is some what arbitrary, with the loose guideline that items which are reusable without change are (mostly) put in class modules, while procedures which are specific to the application are in plain modules.

Thus, I have class modules for Acctg, DateManipulation, ArraySorting, ... but FormManipulation, DbTable & DbQuery operations are (again - GENERALLY) in plain modules. Being all to human, these lines are crossed all to often - but that is the general PLAN.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Mr Red,

Well I thought that too, but I tried to run it and it states procudure to large. So you made all yours in class modules and then how did you contect it to the main form?

Aaron
 
Just call the various proocedures by name with their argument. Mnay of them are just Let/Get functions with a single arg, on some, I generate a UDT to include multple args and pass the UDT. If it is really complex (references a lot of form specific objects), it just goes into a regular module.

It is more 'effort' to set up, but generally easier to maintain. At least that is my experience.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
P.S. I have SEEN procedures which were WAY more than 600 lines of code. They did NOT cause VB1 or VB6 to choke. I, of course, being not able to keep that much logic in my head immediatly started reducing these behemoths to a more moderate size (my goal being to fit on a single page). While I have not yet reached the goal, I do not think I am currently working with any single procedures over ~ 200 lines. Module level Declarations are another story.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top