Greetings,

Take the following example of a form and a form launched from within it.

Dim frmCredit as new frmCredit
frmCredit.showdialog()

Now, in the frmCredit, you have an OK box which does the saving of data,
cleanup, validation, etc.... On one of the validation checks (ensuring that
all required fields are entered) you have the following:

Private Sub cmdOK_click(ByVal sender as System.Object, ByVal e as
System.EventArgs) Handles cmdOK.Click

errorProvider(txtName,"")
if txtName.text.length=0 then
errorprovider.seterror(txtName, "Enter Name")
exit sub
end if

.........

End Sub

Problem: When this validation fails, when the exit sub is called, it closes
the entire form, rather than exiting just the cmdOK_Click event. This then
puts you back at the original form which would create, what I'd term as an
unpleasant user experience.

However, should you change the original call to: "frmCredit.Show()" when
the data validation fails and the exit sub is called, it returns to the
frmCredit as expected. What gives? Anybody work around this with the
showdialog? I'd like to use this call, as it is imperative and the
underlying form relies on the data that is input on the frmCredit.

Michael

RE: Strange Behavior with .showdialog() by anonymous

anonymous
Tue Feb 10 17:01:05 CST 2004

I bet you have the DialogResult for you OK button to be something besides "None" (probably "OK"). This will cause the form to close even if you do an Exit Sub.

Re: Strange Behavior with .showdialog() by Michael

Michael
Mon Feb 16 17:45:58 CST 2004

Bingo, that was the problem, should look closer at that.

mdj


"Jeff LeBert" <anonymous@discussions.microsoft.com> wrote in message
news:43101898-5A5B-49A1-94E3-BE89AAB6DAF7@microsoft.com...
> I bet you have the DialogResult for you OK button to be something besides
"None" (probably "OK"). This will cause the form to close even if you do an
Exit Sub.