B
Bob Day
Using VS 2003, VB.net...
I am confused about the Application.Exit method, where the help states "This
method does not force the application to exit." Aside from the naming
confusion, how do I force the application to exit? See **** below for my
comments/questions in a simple example.
****In Sub Main, the Application.Exit works as expected, other sub main code
is ignored, and when the end sub is reached the application shuts down.
Sub Main
Try
' code
Catch
Application.Exit
End Try
' other Sub Maincode
Call Sub1
end sub
Sub Sub1
Call Sub2
' other Sub1 code
end Sub
**** in sub 2 below, application.exit does not exit the application, instead
it executes without error, but then executes the other Sub2 code, hits the
end sub, then returns to Sub1 and executes the other Sub1 code.
Sub Sub2
Try
' code
Catch
Application.Exit
End Try
' other Sub2 code
End Sub
**** It seems that for the application to exit, you must traverse the call
stack back up to Sub Main and execute Application.Exit in that method, which
Applicaiton.Exit does not automatically do. I know a can create an
exception, and throw it in Sub 2, catch it in sub main, and accomplish
Application.Exit in sub main and exit sub main and I think that would work.
But this seems like a silly way to do it.
How do I exit the application from Sub 2 above? Assume my simple example
above with no forms being displayed.
Thanks!
Bob Day
I am confused about the Application.Exit method, where the help states "This
method does not force the application to exit." Aside from the naming
confusion, how do I force the application to exit? See **** below for my
comments/questions in a simple example.
****In Sub Main, the Application.Exit works as expected, other sub main code
is ignored, and when the end sub is reached the application shuts down.
Sub Main
Try
' code
Catch
Application.Exit
End Try
' other Sub Maincode
Call Sub1
end sub
Sub Sub1
Call Sub2
' other Sub1 code
end Sub
**** in sub 2 below, application.exit does not exit the application, instead
it executes without error, but then executes the other Sub2 code, hits the
end sub, then returns to Sub1 and executes the other Sub1 code.
Sub Sub2
Try
' code
Catch
Application.Exit
End Try
' other Sub2 code
End Sub
**** It seems that for the application to exit, you must traverse the call
stack back up to Sub Main and execute Application.Exit in that method, which
Applicaiton.Exit does not automatically do. I know a can create an
exception, and throw it in Sub 2, catch it in sub main, and accomplish
Application.Exit in sub main and exit sub main and I think that would work.
But this seems like a silly way to do it.
How do I exit the application from Sub 2 above? Assume my simple example
above with no forms being displayed.
Thanks!
Bob Day