Specifies the class or module that contains the Sub Main procedure.
- Required. A full qualification to the Sub Main procedure to be called when the program starts. This may be in the form /main:module or /main:namespace.module. location also can be a class that inherits from System.Windows.Forms.Form.
Use this option when creating an executable file or Windows executable program. If the /main option is omitted, the compiler searches for a valid shared Sub Main in all public classes and modules.
See The Visual Basic Version of Hello World! for a discussion of the various forms of the Main procedure.
When location is a class that inherits from System.Windows.Forms.Form, vbc.exe lets you compile code at the command line that was created in the development environment:
' Compile with /r:System.dll,SYSTEM.WINDOWS.FORMS.DLL /main:MyC. Public Class MyC Inherits System.Windows.Forms.Form End Class
To set /main in the Visual Studio integrated development environment
- Open the project's Property Pages dialog box. For details, see <Projectname> Property Pages Dialog Box.
- Click the Common Properties folder.
- Click the General property page.
- Modify the Startup object property.
To set /main programmatically
- See StartupObject Property.
The following code compiles
t3.vb, specifying that the Sub Main procedure will be found in the
vbc t2.vb t3.vb /main:Test2