Programs Ends when form button is clicked.

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I am teaching myself visual basic .net 2003. I bought a book and worked the
examples, but I cannot figure out what I am doing wrong on my first
application.

I have a form that is called from a module:

frmSelectGroup.ShowDialog()

This works fine and the form opens. On the form, the user is asked to
select some options and then click "Continue". When the "Continue" button
is clicked, the program goes to the "End Sub" line of the Private Sub
Button1_Click and then ends. The program never returns back to the module
to finish the rest of the code in that section.

Am I missing something obvious?

Thanks...
 
Greg said:
I am teaching myself visual basic .net 2003. I bought a book and worked the
examples, but I cannot figure out what I am doing wrong on my first
application.
This works fine and the form opens. On the form, the user is asked to
select some options and then click "Continue". When the "Continue" button
is clicked, the program goes to the "End Sub" line of the Private Sub
Button1_Click and then ends. The program never returns back to the module
to finish the rest of the code in that section.

Am I missing something obvious?

Are you closing the form? ShowDialog is "modal" which means that no more
code will run in the calling routine until the form is closed.

There are several ways to close the form, for example:

Me.Close()

or

Me.DialogResult = DialogResult.OK

Using DialogResult is nice, because you can read the result back in the
calling code - eg. did the user click OK or Cancel?

You can also give a button a DialogResult property, which has the same
effect.

Tim
Tech writing here:
http://www.itwriting.com
 
Back
Top