BYTEINSIGHT
GAPVelocity AI Studio helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
Standard EXE applications written in VB6 can be started either from a Main sub or a startup form which is set in the project properties. The use of the Main sub is a very common practice in large applications, because it allows the execution of initialization logic before the load of the main form of the application, and allows a separation of this logic from the logic of the form.
When an application that uses the Main sub as startup object is migrated using the VB6 AI Migrator, equivalent code is generated in .NET, however, due to differences in the behavior of VB6 and the .NET Framework the applications behave differently. Some manual changes are required to achieve functional equivalence in this case.
In VB6, all the code in the Main sub is executed and the method ends, but the application continues to run while a form is displayed. In .NET on the other hand, the application will exit as soon as the Main method exits, any open form at that point will be closed automatically.
See also: How to prevent the application from exiting immediately after starting?
Public Sub Main() Form1.Show Dim x As Integer x = 10 MsgBox x End Sub
'UPGRADE_WARNING: (1047) Application will terminate when Sub Main() finishes. <STAThread> _ Public Sub Main() Application.EnableVisualStyles() Application.SetCompatibleTextRenderingDefault(False) Application.Run(Form1.DefInstance) Dim x As Integer = 10 MessageBox.Show(CStr(x), My.Application.Info.Title) End Sub
//UPGRADE_WARNING: (1047) Application will terminate when Sub Main() finishes. [STAThread] public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(Form1.DefInstance); int x = 10; MessageBox.Show(x.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); }