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.
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
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?
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.