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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Moduals Vs. In Form Code? 2

Status
Not open for further replies.

LindaC

Programmer
Oct 18, 1999
97
US
Hi All, I am writing my first VB program and could use a push in the right direction.

The Tax Map Dept. keeps track of all property sales/ownership and land changes for the county ie when a parcel is split. When the project is complete the program will manage 2 data bases for the Tax Map Dept.; 'active' records and the 'deleted' records.

I have managed to get the logon screen working and the Main Menu. The user is able to pick what task they wish to preform add, update, inquiry or delete a record. They can also supply a key or partial key to begin the search for records. There are really only 2 forms left to design. One to list partial info on a group of records and one to display all info on one record. There are, however, 13 different functions the user can perform if they have full access. Here is where my question comes in.

Should I:

1) Create one form and a class moduale for each function and call/perform the modual from the form or
2) Create a form for each function or
3) Create one form and put all code there

Thank you for your time. Linda C.


LindaC
lcastner@co.orange.ny.us

 
I would split things up. Once your program gets large it gets hard to find problems. This is just me and totally up to you on how you want design your program, there is no exact answer here.

What I do is split up my modules like this.

Forms - All my forms only have the form procedures, and validation checking. I have a data validation function in a the main code module, from each text box I call the function from the KeyPress event. Then I have all the form resizing and etc in the form code window.

Code Modules - I keep the following as my base code modules, that way they are re-usable in other projects. i add new ones as the need arises for the specific project. Note some of these are also class modules as it is easier to work with in some respects.

modValidate.bas - All my data validation functions are here. I check to make sure an alpha key isn't pressed for a numeric text box, and I check lengths of data.

modData.bas - I keep all my database functions here. They are mostly re-used anyway.

modCode.bas - I put all my code here, the code that is program specific.

clsErrHandler.cls - I put all my Error handling and trace file funcftions in here.

clsRegistry.cls - I do all my registry entries in this. i.e. Get settings, save settings, fidn system settings etc. This si a base module that I customize with each app.

I don't think I forgot anything but at least it shows what 1 programmer does Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Hi Craig, Thanks for the info!! Is there a difference in the code/syntax between the form, a .bas program and a .cls program? Yes, I am learning VB on the fly :)

LindaC
lcastner@co.orange.ny.us

 
I'll go through the basics of what the extensions mean.

.frm is a Form, meaning it actually shows something on the screen.

.bas is code only.

.cls is code as well but it kept in a class. So rather than just calling the function in the cls like you might in a bas, you have to create the object first. This is nice if you know what your doing, but as your a beginer stick with bas. There isn't much difference run time wise.

.vbp is the container of the project. So it keeps a listing of all the forms and mosules in your code.

You might want to jsut start with programming in the forms for now. As you get more experience you can start moving that code into modules. and etc. Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Hi Linda

What a small world! I work for a company similar to yours: I write Appraisal, Asseessment and Tax Collection programs for County Govt, so I KNOW what you're going through! lol

I have to agree with Craig, In VB Code, Smaller IS better! I would much rather have a hundred .bas and .cls modules that are well named than have all in a form. I actually only use the form as a place to put controls and to call any procedures/funtions I need as a Boolean. For instance, if the user clicks on a combo box to find a parcel, I pass it on to a .bas and return a T or False to the form itself (as to whether or not it could find the record). I AM somewhat partial to putting the Database interfaces and accesses into a separate class though. A terrific book that explains it very well is: Beginning Visual Basic 6 Objects by Peter Wright. Published by Wrox. It helped me tremendously!

Good Luck!
Dave
 
Thank you both for the info. I have managed to take code from my Main Menu form and create a .bas file and it works correctly :)

LindaC
lcastner@co.orange.ny.us

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top