Weird VB .Net Question

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Hi,

I am trying to do something that should be EASY but is not working for
me for some reason.

My application opens to a Main form, similar to a SwitchBoard in Access.
What I am trying to do, and I may not be doing the best thing, is hide
the Main form, and open whatever form the user is trying to use. This
works fine with the following sample code:

Dim Second As New Form2()

Me.Hide()
Second.Show()

My problem is closing form2 and reopening the Main form. I tried using
code like this:

Dim first As Form1

first.Activate()
Me.Close()

Nothing I try works. Tee second form closes, but the first one never
shows. I have tried doing the second form code like the one I used from
the Main form, but nothing works.

HELP!

Randy
 
Using the Show() method runs asynchronously as opposed to its synchronous
counterpart ShowDialog()

In order to get what you want to work you have to know that the form 2 is
closing. However, with your method, it is only possible that one form be
open at a time treeing of the first form..

So instead...

Private sub Button_Click(sender as object, e as system.eventargs) handles
button.click

dim frm2 as new Form2

me.hide()
frm2.Showdialog()
me.show()
frm2 = nothing

end sub
 
Back
Top