title: 'Exit Sub' on DialogResult.OK button
body: <p>I have a <code>VB.NET</code> form (<code>CopyScenarioForm</code>) with a OK button (<code>DialogResult property = OK</code> ) and also assigned it as <code>Accept Button</code> for the Form.   </p>
  
  <p>I show this form from my main Form (<code>mainForm</code>) using </p>
  
  <pre><code>If DialogResult.OK = CopyScenarioForm.ShowDialog() Then
        DoSomething()
  End if
  </code></pre>
  
  <p>Now when user clicks on the <code>CopyScenarioForm.OK</code> button, I want to validate his entries and if invalid I want to <code>Exit Sub</code> from the <code>OK</code> button's click handler but when I do that the form still closes out and <code>DoSomething()</code> 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 <code>OK</code> button's <code>DialogResult</code> property to <code>NONE</code> instead of <code>OK</code> then it doesn't cause it to close. but then how Do I know how the user exited the form to execute <code>DoSomething()</code>?.  </p>