Standard BAS Module (VB6)
Standard BAS Module (VB6)
COM
Visual Basic Tutorial & Resource Center
Home
Search
Visual Basic stores its code in the form of module that makes your program more structured. So its
very important to learn about it.
What is a module?
Module is a separate code file in Visual Basic that contains procedures and declarations.
Your entire VB6 program code does not come line by line. Instead they are separated in code files
called modules, each of them is separated into procedures. Thus your VB6 program becomes well
structured which is the key part of developing Visual Basic applications.
Form Module
The complete code including procedures and declarations part of a form is referred to as the form
module.
A separate project file with the .bas extension is saved on your hard disk as soon as you add a
standard module to your current project. You can change the Name property of your newly added
standard module from the properties window. Choose a meaningful name, it will benefit you while
writing the code.
The modules are shown in project explorer window
The variables and constants declared using the Public keyword in the Declrations section of the
module are global, accessible from all parts of your current application.
'In form1
Private Sub cmdShow_Click()
Dim num As Integer
Dim m As Integer
num = InputBox("Enter the number", "Input")
m = Module1.increment(num)
MsgBox m
Call Module1.show
End Sub
' In Form2
Private Sub Form_Load()
Call Module1.show
End Sub
' In Form3
'The show sub procedure is global
Private Sub Form_Load()
Call Module1.show
End Sub
Note: BAS modules are especially useful in large projects. So if you're developing a big VB6
application, include them.
Like
Google +