Formless VB6 App

No, it’s not exactly a console app, but it’s possible to create a functional VB6 application that doesn’t have a form in it. Quite confusing and surprising even to most long time VB6 programmers and they even think it’s a joke 🙂

And their reactions are valid, since every time you create a new project in VB6, which is normally a Standard EXE, the IDE (Integrated Development Environment) always give your project a form, right? Yes, that’s right — it’s not a trick question 🙂

Okay, so let’s do it and prove that it’s possible.

Create a new Standard EXE project and don’t do anything yet.

Instead, go ahead and right-click the Form1 and click “Remove Form1” from the menu:


Your project would now look like this:


So let us now add a new (basic) module.

Right click on the project, then click or expand “Add” and select the “Module”:



A popup window will ask you to either create one or use an existing. Stick to the default (New), make sure the “Module” icon is selected, then click “Open” to add it to our project:


Your project now has an empty basic module like this:


Next, just type the following inside this basic module:

sub main()
    MsgBox "See? No forms", vbExclamation, "Happy"
end sub

Run the project and you should see the message box appear:


So we know that our code ran, but how did that happen? 🙂

The answer lies in one of the items in the Project Properties, so let’s go ahead and open the Project Properties:


Under the “General” tab, on the right side you’ll see a “Startup Object:” with a dropdown menu which now says “Sub Main” and coincidentally matches what we typed, right? 🙂

That’s the reason why it’s possible to create a VB6 application without any form, because it doesn’t require one. 🙂

Doesn’t mean you can’t have forms later on, but if you don’t need any, like when you just want to create a command-line utility then there’s no point in having a form that will never be used, and this is when you’ll apply this idea/concept.


If you have not noticed before, a regular project simply selects “Form1” as the Startup Object (see image below), but you can clearly see that the “Sub Main” is always there and you cannot remove it — it’s there whether you have a form or not.

Here’s what a regular Standard EXE project looks like from the Project Properties window:

Other Use Case(s)

Setting up “Sub Main” isn’t just for creating formless VB6 apps.

You can implement this technique to pre-determine which form to load during startup.

For example, you check a condition inside this Sub Main and depending on the result, you launch the appropriate Form.
An exaggerated example is launching a different form based on a command line parameter


Obviously, you’re not gonna do this in production 🙂


But this is just to illustrate the idea. In the real world, you would use the command line argument and check those against a secure database and then run the corresponding routine, etc.

Point is, using “Sub Main” as the Startup Object gives you a lot of options and/or flexibility in designing your application. And it’s not restricted to Standard EXE, this also works on ActiveX projects too, so start exploring and writing advanced software 🙂

Here’s the link to my GitHub page with the full source codes:

https://github.com/vegitz/codes/tree/master/0006%20Formless%20VB6%20App

Leave a Comment