469,903 Members | 1,874 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Closing an application when catching a fatal error

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
2 1229
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
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.

Similar topics

2 posts views Thread by Alexey Kouzmitch | last post: by
5 posts views Thread by Ron L | last post: by
5 posts views Thread by Jason MacKenzie | last post: by
10 posts views Thread by John Kraft | last post: by
14 posts views Thread by =?Utf-8?B?UHVjY2E=?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.