What is the equivilent of "Exit Sub" in C#?
Also, what statement will cause the form to close if a condition isnt met? For example, I want to close a form if someoneclicks Cancel to open a file.
Thanks for all your patience!
Printable View
What is the equivilent of "Exit Sub" in C#?
Also, what statement will cause the form to close if a condition isnt met? For example, I want to close a form if someoneclicks Cancel to open a file.
Thanks for all your patience!
"return"
To close a form, just use "this.Close()"
I did that but it still went through the form_load funciton anyways. Unless that will not work in form_load?
It would be of help if you could post the code you are currently using...
Once you call Show on a Form the Load event is raised and the Load event handler is executed. Even if you call Close within the Load event handler the the method will continue until it reaches and exit point and the form will be displayed, but only for a moment. If you want to do something first that will affect whether a form is displayed then do so before calling Show. Don't call Show if you don't, or might not, want to Show it.
you could make youself a new public function, like .TryShow on your form, which will test whatever it is you are etsting for, and from there it either calls .Show or doesnt.
this will save you having to modify your other code, and allow you to re-use it.