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

modules

Status
Not open for further replies.

compnut24

Technical User
Jun 11, 2001
67
US
i want to streamline my code into modules. what exactly is a module, and how to i make one, and how do i call it and get its results?
 
So many terms, and only one solution. Forgive me if I lead you on the wrong path, but remember this one bit of advice. You're not responsible for what other people think, and are unable to control the thoughts of others. But your question reminds me of the joke "What's the difference between the Negro, Colored, Black Man, or African-American?
In computer land, we have a similiar joke, What's the difference between a module, function, procedure, subprogram, or method?
If you know what you're doing when you write code, you'll do just fine! In my opnion, for Visual Basic users, an module is the same as a subprogram. If anyone tells you different, tell them to place a Visual Basic module side by side with a Visual Basic subprogram and explain the difference.
 
Projects-Add Module

In a module, you will keep variables and functions, subs, etc. that you will share between 2 or more forms. It will produce smaller exe. as code is not repeated. Code that is specific to only one form, should be kept in that form. And as far as calling a function that is in a module, your program will look first in it own form, then look in any modules you have so no extra coding is used. Your program can also have more than one module, so you can organize things as you see fit.

David Paulson


 
A module is essentially used for reusability of the code. also you can use a class module to implement object oriented programming.

you can add a module(standard/class) by right clicking on the project->add in the project explorer or by clicking on the arrow adjacent to ADD FORM button on toolbar and selecting the required module.

it is a good idea to keep related functions in a single module so that when you need these functions again in another project you just include the same module. for example you could have a module named fileops which has all the file operations (create,delete,move copy,open etc.) with the appropriate error handling which you could then use in all your projects which deal with files.

regards,
manish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top