Weird VB .Net Question

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
 
C

CJ Taylor

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top