More Validation and Cancel

Edit Big Time: Setting e.Cancel = false in the form closing event actually let's you exit the program.  Go figure.  And I feel like an idiot for not figuring this out sooner.  Is today still Monday or something?

A little clarification on my post about trying to "cancel" on the Validating event.  I understand how to work around this behavior, but I think all the work arounds I've seen so far suck.  The work, but it sucks to have to resort to these things.

I'm not trying to just "get this work" on a form.  In one of my classes I teach, they spend a decent part of a chapter and lab on working with the Validating event.  I would really like to not have to talk about detecting WM_CLOSE messages, figuring out where the mouse is located and also keeping track of when the Close method of the form is being pressed in order to properly set e.Cancel = true on a TextBox.  I'd rather just juggle things in the Leave event VB5 style. 

My official answer is "don't set e.Cancel = true in the validating event because you won't be able to close the form down.  Plus, nobody likes being stuck on an invalid field anyways" until someone can point towards something that, well, works normally.

No Comments