DEV Community

Muriithi Gakuru
Muriithi Gakuru

Posted on

BC30420 'Sub Main' was not found error in a Windows Form app: Quick Fix.

It's safe to say that Visual Basic has become one of the hardest languages to find content about online ever since Microsoft announced that there won't be any more features added to it in .NET CORE/ .NET 5.

 “ Going forward, we do not plan to evolve Visual Basic as a language ”
.NET Team

That explained a lot when I tried to troubleshoot an error I'd gotten and the whole of the internet was almost blank, for an error I'd call trivial and noob level. I've recreated the above error so as to show you how to solve it. Save you time.

Screenshot (46).png

Every time I tried the compile and run the project, i got and error that the Sub Main()

was not found.
The solution to this is to check that the startup form isn't referencing to an old method. You can find that in your project properties.

  1. All you have to do is right-click on your main project in the top-right area of the visual basic working area.

Screenshot (47).png

  1. Scroll to the bottom and click on properties.

Screenshot (48).png

On the new window right at the Startup Project section is where you're going to change from
Sub Main

to the name of your Form.
Screenshot (49).png
Once you're done, you can exit that tab and re-run your project.

Screenshot (51).png

Everything should be working fine and you can notice that the error is gone.

Conclusion

Every day is a coding challenge. If you feel that the content was inadequate please comment about it or contact me. Keep coding. Cheers !!

Top comments (0)