Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21089

[RESOLVED] How do you create a Main Module?

$
0
0
Hi, I am new to Visual Basic and am just getting to know the basics. I have already run a few programs that are based on forms.

One thing that I wanted to do was to initialise some variables in a piece of code that is run when I start the program.

My understanding is that I can create a procedure 'Main' in a Module that would be run when the program starts. My intention was to use this code to initialise my variables.

MSDN has the following:

' A "Hello World!" program in Visual Basic.
Module Hello
Sub Main()
MsgBox("Hello World!") ' Display message on computer screen.
End Sub
End Module

When I create a module using Project / Add Module and then paste this code in and try to run it I get an Invalid Outside Procedure error.
Please let me know what I am doing wrong.

Viewing all articles
Browse latest Browse all 21089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>