I have a VB.NET
form (CopyScenarioForm
) with a OK button (DialogResult property = OK
) and also assigned it as Accept Button
for the Form.
I show this form from my main Form (mainForm
) using
If DialogResult.OK = CopyScenarioForm.ShowDialog() Then
DoSomething()
End if
Now when user clicks on the CopyScenarioForm.OK
button, I want to validate his entries and if invalid I want to Exit Sub
from the OK
button's click handler but when I do that the form still closes out and DoSomething()
gets executed. Is there a way to stop this and keep the form alive and only exit if the inputs are valid. I noticed, if I change the OK
button's DialogResult
property to NONE
instead of OK
then it doesn't cause it to close. but then how Do I know how the user exited the form to execute DoSomething()
?.