By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Closing an application when catching a fatal error

P: n/a
Hi,

I've a form.load event that initializes a cardreader, which is crucial to
the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of the
code (initializing a browser component and adding some images to buttons).
Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come
in handy too :)
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Initialize your cardreader in a sub main(in module). If cardreader
doesnt throw an exception show the Form. Of course make sub main your
startup object.

Public sub Main

Try
'Initialize CardReader Here
Dim frm as new Form1

Application.Run(frm)
Catch ex as exception
Messagebox.Show("An Error has Occurred")
end try
end sub

Ken
----------------------------
"Silby" <Si***@nothanks.net> wrote in message
news:ek********************@phobos.telenet-ops.be...
Hi,

I've a form.load event that initializes a cardreader, which is crucial to
the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of the code (initializing a browser component and adding some images to buttons).
Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come
in handy too :)

Nov 20 '05 #2

P: n/a
Ahh, excellent.
Thanks for the tip !

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
Hi,

Initialize your cardreader in a sub main(in module). If cardreader doesnt throw an exception show the Form. Of course make sub main your
startup object.

Public sub Main

Try
'Initialize CardReader Here
Dim frm as new Form1

Application.Run(frm)
Catch ex as exception
Messagebox.Show("An Error has Occurred")
end try
end sub

Ken
----------------------------
"Silby" <Si***@nothanks.net> wrote in message
news:ek********************@phobos.telenet-ops.be...
Hi,

I've a form.load event that initializes a cardreader, which is crucial to the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of

the
code (initializing a browser component and adding some images to buttons). Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come in handy too :)


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.