I'm missing sub main - Adequate coding style

T

Thilo Kerner

Hello!

In VB6 I used to do all preparation in my Sub Main which Microsoft wants
me to abandon. I guess they have a good reason (but which?), so I would
like to go with it.

Can you please tell me when you do your preparation, e. g. checking for
corrupt database, establish database connection, check for license,
build GUI?

Do you all use a start/ splash screen if your application is a bit larger?
Do you program like this (Tarzan style)? ->

(My start form is frmSplash)
(Now in frmSplash...)

sub Timer1_Timer()

call PrepareAllStuff
If m_bLicensed then
frm1.show
else
frm2.show
end if
unload me

end sub

I described it a bit weird, sorry, but I hope you understand what I mean.

Thank you!
Thilo.
 
R

rowe_newsgroups

Hello!

In VB6 I used to do all preparation in my Sub Main which Microsoft wants
me to abandon. I guess they have a good reason (but which?), so I would
like to go with it.

Can you please tell me when you do your preparation, e. g. checking for
corrupt database, establish database connection, check for license,
build GUI?

Do you all use a start/ splash screen if your application is a bit larger?
Do you program like this (Tarzan style)? ->

(My start form is frmSplash)
(Now in frmSplash...)

sub Timer1_Timer()

call PrepareAllStuff
If m_bLicensed then
frm1.show
else
frm2.show
end if
unload me

end sub

I described it a bit weird, sorry, but I hope you understand what I mean.

Thank you!
Thilo.

Personally I almost always disable the application framework and start
my application from a Sub Main. I don't like the way Visual Basic
starts the application "automagically" I prefer the C# way of doing it
myself. Like I said, this is just my opinion - and may differ greatly
depending on who you talk to.

Thanks,

Seth Rowe
 
T

Thilo Kerner

Thanks to you as well!

Okay, I'm one step further: There con's and pro's.

So what the application framework does is applying XP styles, checking
for instances, adding an event handler for the network connection and
one for unhandled exceptions, right?

Best regard,
Thilo
 
S

Stephany Young

Amongst a lot of other things.

The point is that the Application Framework generates the code for this at
compile-time but does not expose the code as such.

For a lot of simple apps, the Application Framework is all that is needed,
but when you need to do something different or, for that matter, choose to
do things differently then all you need to do is disable the Application
Framework and roll your own Sub Main(...).

It's not rocket science, it's purely a matter of choice.
 
C

Cor Ligthert[MVP]

Thilo,

I completely agree with Stephany, how many times do you start a real new
project, for a simple form the way it is done fits me the best.

However, depending on the project is in my idea in a form project the form
the best place to start with. That can be a mdi form or a form what uses
many user controls.

But coming more to your sample, from a start form a splash form is in my
idea much eaiser to make.

Cor
 
C

Cor Ligthert[MVP]

Hi Cor,

I really don't understand what you write.
But coming more to your sample, from a start form a splash form is in my
idea much eaiser to make.

Do you mean that you use a normal form and than start from that your splash
form? I agree with you: that's very easy to do.

Cor
 
K

Kevin S Gallagher

Could you not use MyApplication.MyApplication_Startup procedure to work like
Sub Main and from here allow the startup form to do it's job? I realize it's
not the same as VB6 but perhaps usable to some degree or may be a better
solution then Sub Main.
 
J

Jan Hyde (VB MVP)

Thilo Kerner <[email protected]>'s wild thoughts were
released on Thu, 16 Aug 2007 01:47:11 +0200 bearing the
following fruit:
Hello!

In VB6 I used to do all preparation in my Sub Main which Microsoft wants
me to abandon. I guess they have a good reason (but which?), so I would
like to go with it.


I still find sub main is the best way to go. Only in certain
apps do I go with a startup form.

J
 

Ask a Question

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.

Ask a Question

Top