|
-
Jul 13th, 2004, 01:52 AM
#1
Close one form, Show the other! [resolved... blah]
I know this has to be the world's easiest VB.NET question!
Here's what I want: Show form1. Press the button on Form1, and form2 should show up. Form1 should then close.
Here's what I did
In a module:
VB Code:
Module Module1
Public f1 As New Form1
Public f2 As New Form2
Sub Main()
f1.ShowDialog()
End Sub
End Module
In form1's button:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
f1.Close()
f2.Show()
End Sub
And that's it!
Now when I click the button, form2 appears briefly and then disappears.
Surely it has to be something simple. What am I missing?
Last edited by mendhak; Jul 13th, 2004 at 04:04 AM.
-
Jul 13th, 2004, 03:13 AM
#2
f1 needs to be closed, so I cannot let it stay in memory.
-
Jul 13th, 2004, 03:57 AM
#3
VB Code:
Module Module1
Public Sub Main()
Dim MyForm As Form 'early-binding good :)
MyForm = New Form1
MyForm.ShowDialog()
'wait until form1 closes
MyForm = New Form2 'this kills the form1 instance
MyForm.ShowDialog()
End Sub
End Module
'in form 1's button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
I think its about time the "Late-Binding Demon" payed mendhak a visit, don't you kids? What a naughty froggy!.
I don't live here any more.
-
Jul 13th, 2004, 04:02 AM
#4
I hug wossname!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|