This documentation is archived and is not being maintained.

Sub Main will not be called at component startup

Visual Studio .NET 2003

In Visual Basic 6.0, any code in a Sub_Main procedure for a .dll or .ocx file would be run automatically on startup. In Visual Basic .NET, Sub_Main cannot be set as a startup object; any code in the Sub_Main procedure will not be run on startup.

What to do next

  • Add code to the constructor (Sub New) to call the Sub_Main procedure whenever an instance of the object is created:
    Public Sub New()
    End Sub
  • Alternatively, move the code from the Sub_Main procedure to the Sub_New procedure.

See Also

What's New in Components and Component Authoring