Modules are reusable codes that you can use throughout your application development.
A module can store public functions or group of functions that you can call when
needed, rather than to code it again and again, module also reduces development time
and keeps your code area clean.
Follow the sample below to create a simple module.(The sample is a simple program
that uses module to show a message box)
Note: Please click the photos to enlarge.
Step 1. Create a new Windows Application. Then click Project in Menu Bar then under
the list click "Add Module". Please refer with the photo below.
An Add New Item Window will appear, similar to the photo next to Step 2.
Step 2. Click "Add" button to create the module. May may change the Name of your module
by typing on the module name textbox. The Default name is Module1.
The next picture shows the code view of your module
Step 2. Type the following code in the code area of your module.
Public Sub ModuleSample()
MsgBOx("This is a sample module message")
End Sub
Refer with the photo below.
Step 3. After creating the codes. Select the Form1 Design Tab and create a button.
Step 4. Now double click the button or switch to code.
Step 5. While on code view of Form1, click Module1 tab, and copy ModuleSample()
Follow the two (2) consecutive photos, for reference.
Step 6. Then switch again to Form 1 code view and paste ModuleSample()
Step 7. Run the program (Press F5). Then click the button on Form1. You must have
a result similar to the photo below.
That's it, you got a Simple Sample on how to create a module in VB.Net. I hope you learned something today, until next time. Thank you.
For your comments and suggestions, please comment.