0

Hello, I am experiencing a very unusual problem. If an exception occurs within my Frm_Load method which handles MyBase.Load, the method simply ends, a nice message is printed to the debug windows explaining the error, and program execution continues. The problem is, I want an error in the Load method to crash the program. VB simply decides to ignore the rest of the code after the exception but continues program execution; this causes many initializations to never be performed in my program.

How can I make my load method halt execution when an exception is thrown?

Thanks,
Patrick

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by PerplexedB
0

You can execute the code that triggers the exception in the caller routine between the instantiation of the form and the show(). If the error is triggered, you can then not call the show event.
Not sure how "kosher" this solution is but it would be something like this:

dim o as myForm = new myForm
dim loadForm as boolean = true
try
    code
catch e as exception
    loadForm = false
endtry
if loadForm then
    o.show
endif

Edited by PerplexedB

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.