G
Geoff Jones
Hi
What is the closest equivalent to Main in a VB.Net form?
Geoff
What is the closest equivalent to Main in a VB.Net form?
Geoff
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Geoff Jones said:What is the closest equivalent to Main in a VB.Net form?
Or simply select the Form's class as the startup object. VB.NET will see theIn the project properties, select 'Sub Main' as the startup object.
VB.NET will see the Form class has a Shared Sub Main & use it, rather
then implicitly adding one.
Cor Ligthert said:Nice multiple choise thanks and nice showing of all the possibilities as
well.
This answer from me only for a webform or windowform project, than I find
B the nicest and can not see a reason for all those others than that it is
old fashion use.(By a lot of people used as good practise).
Does that go for other classes as well? For example Windows Services, putsWhat I (personally) don't like is a 'Sub Main' defined inside a form.
Does that go for other classes as well? For example Windows Services, puts
the Sub Main in the class derived from ServiceBase. When I define a system
tray application I normally put my Sub Main in the Main Component (the
object that manages the context menu & notify icon objects).
Do you normally define it in a Module? What do you normally call the
module.
When I define my Sub Main in a module I normally call that module
MainModule. This is one of the few times I actually use a Module.
As I stated, I normally define my Sub Main in the MainForm, especially
when there is a "well-defined" MainForm...
True, every application has a starting point however with the introductionI don't see why using 'Sub Main' should be old-fashion. Every application
has a starting point, and if the developer wants/needs to influence the
startup of the application, defining a 'Sub Main' is the way to go.
What I (personally) don't like is a 'Sub Main' defined inside a form.
"reintroduced"?certain method was leaved then. That is now reintroduced in VBNet, I find
that an improvement again.
)Yes this is largely a discussion of personal preference.That's a discussion about personal preference...
Agree.Nevertheless, when taking a look at the projects which can be found on the
web, it's often hard to locate the 'Sub Main'/'void Main' there because
people use unmeaningful names for their classes/forms.
VB1 thru VB6 had the ability to define a "Sub Main" in a module to be used
as the entry point instead of an actual form. (Yes I just checked the VB1
manual)
)Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.