What is the difference between module and form in vb

Hi everyone, I need a bit of clarity when it comes to the difference between module and forms in vb
Joel SiiiAsked:
Who is Participating?
Pawan KumarDatabase ExpertCommented:
Form - GUI ( graphical user interface ) It is something that the the user will have interaction with. It can and usually does contain code specific to the controls that exist on the form. These might be buttons, listboxes, etc.

A module in vb is used to encapsulate code. At its purest form a module would contain code used for specific tasks and a new module would be used for other specific tasks.

In the past, I have created modules that contain utility routines that I find I use frequently. I can then include the module of my utility routines into any new project I have and reuse that code.

Code or functions/subs in a VB form can be addressed using the Me prefix. A module does not exist within a form, so that context is not available.

A module would be a part of the application.

From old EE database.
Martin LissOlder than dirtCommented:
A module does not exist within a form, so that context is not available.
That's not true. The code behind forms/userforms is referred to as the "form module".
Forms are modules, but they are also a class.  Apart from the obvious (A form has a UI), this is the main difference.  

A module is not a class.  

With a class you can create an instance, which you can't do with a module.  You can also called static methods which is like calling a sub or function from a module.
Máté FarkasDatabase Developer and AdministratorCommented:
Form: this is an object which copies a build in class UserForm in VB. Your Form object has some initial capabilities:
      - has a window with common window controls (close, minimize, maximize, resize with mouse)
      - can draw itself on the screen (with Show method) or hide (with Hide method)
      - can contain other control like buttons (CommandButton), text fields (TextBox)
      - can manage keyboard and mouse events
      - etc. you can extend the capabilities with your methods and controls
Form is similar to Class.

Module: this is only a code file which contains some functions, procedures, variables which are independent for any other Forms or Classes. You can call your functions from your module in any part of your program.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.