http://www.vbinfozine.com/t_wfdlg.shtml
But what if I want to do some validation WITHIN the button's Click event handler and if the validation fails, I DON'T WANT to close the dialog?
First solution: Set OKCmd.DialogResult = DialogResult.None (string "None" in the designer) and close the form manually:
Second solution: Leave the OKCmd.DialogResult = DialogResult.OK, but prevent the form to automatically close when the user enters invalid logon information. Here is how: