Hi Alice,
You're closing the main form of the app, I suspect. This form is the base
form, so the programs exits.
What you have to do is make the main form an mdi container (in its
properties). Then develop a simple menu for that form; have one of the menu
options open a child form, which then has a button that can open a different
child form and close itself, etc. This way, the mdi container (the parent
form) remains open all the time and serves as a lauching point for any menu
option you place in it.
If you need some help setting this up, try first to do it and let me know
where you run into a problem. The menu calls should look something like
this:
Private Sub MenuItem31_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem31.Click
Dim newmdichild As New formfirst
newmdichild.MdiParent = Me
newmdichild.Show()
End Sub
Then, inside formfirst, a button click event like this to launch a different
form and close itself:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newmdichild As New formsecond
Me.Close()
newmdichild.Show()
End Sub
HTH,
Bernie
Alice said:
Hi Bernie,
My original code (using ShowDialog) just left every form
still open, but the program didn't break. So I changed it
to .Show(), and it suddenly exits the program. Here is the
message it gives after it crashes:
The program '[3088] TravelCenter.exe' has exited with code
0 (0x0).
Here is the code I'm using:
Private Sub btnEnter_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnEnter.Click
' Open the Main Form
Dim objMain As New frmMain()
objMain.Show()
' Closes Welcome Screen
Me.Close()
End Sub
Thank you for your help!
-----Original Message-----
Hi Alice,
I have a password form that closes when the correct pwd is entered; works
very simply but it does not directly open the next form, as it opens an mdi
container that ultimately is the base form of the mdi app.
However, opening one form from another is pretty easy. I tested the
following with 2 forms - formfirst and formsecond. This is the code from
the first form,which opens the second and closes itself.
Dim newmdichild As New formsecond
Me.Close()
newmdichild.Show()
Now the code for the second form is the same, except it calls formfirst.
This works fine with show(), but with showdialog(), it exhibits strange
behavior - each remains open and simply displays a second, third etc
instance of itself.
Can you show me your code, and the error message you get when the program
breaks?
HTH,
Bernie
.