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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.