Form creation and program flow

  • Thread starter Thread starter Rob Richardson
  • Start date Start date
R

Rob Richardson

Greetings!

I am a VB6 programmer just learning .Net. In the VB6 world, I am used to
creating a form, calling "MyForm.Show vbModal", and then assuming in the
next step that information on the form will be complete and available. I
don't see the equivalent construct in .Net. If I call MyForm.Show(), the
form is shown and execution immediately proceeds with the step after the
call to Show(), as though I had used vbModeless in the VB6 world.
Application.Run(MyForm) will show the application's main form. Can I call
that at any time, for any form? I got the impression from the help page
that Application.Run() is just for the main form of the app. What is the
preferred way to get modal display of a form in VB .Net?

Thanks very much!

Rob Richardson
 
Rob Richardson said:
Greetings!

I am a VB6 programmer just learning .Net. In the VB6 world, I am used to
creating a form, calling "MyForm.Show vbModal", and then assuming in the
next step that information on the form will be complete and available. I
don't see the equivalent construct in .Net. If I call MyForm.Show(), the
form is shown and execution immediately proceeds with the step after the
call to Show(), as though I had used vbModeless in the VB6 world.
Application.Run(MyForm) will show the application's main form. Can I call
that at any time, for any form? I got the impression from the help page
that Application.Run() is just for the main form of the app. What is the
preferred way to get modal display of a form in VB .Net?

Thanks very much!

Rob Richardson

MyForm.ShowDialog() is what you are looking for...

Lorne
 
To display a modal form instance use

------------------
Dim objForm as new MyForm ' Where MyForm is the name of your form class
objForm.ShowDialog
------------------

One thing to remember in .net that Forms are just classes like any other
object - you have to create an instance before you can use it. VB6
automatically created the instance for you - .net doesn't.

HTH,

Trev.
 
Back
Top