|
-
Jun 27th, 2003, 02:19 PM
#1
Thread Starter
Junior Member
Basic question regarding closing forms.
Hi!
I just recently stared working with VB.net and I've noticed several differences. One of them is confusing me.
It has to do with the basic handling of forms.
In my case I have a main form where I have a button which when a user activates should bring up another form and hide the main one.
The code behind that command button look like this:
If radCMBO.Checked = True Then
Dim frmCMOB As New frmCMOB()
frmCMOB.show()
ElseIf radCMBB.Checked Then
Dim frmCMBB As New frmCMBB()
frmCMBB.show()
Else
Dim Front As Integer
Randomize()
Front = CInt(Int((2 * Rnd()) + 1))
If Front = 1 Then
Dim frmCMOB As New frmCMOB()
frmCMOB.show()
Else
Dim frmCMBB As New frmCMBB()
frmCMBB.show()
End If
End If
Dim frmCMOB As New frmCMOB() 'this opens one of my new forms
frmCMOB.show()
but what should I write in order to close my main form after opening a new without closing the whole app? The user should be able to return to the main form
frmCMBB and frmCMOB
Any help would be appreciated..
Thx.
-D
-
Jun 27th, 2003, 02:25 PM
#2
Sleep mode
Originally posted by Deloma
but what should I write in order to close my main form after opening a new without closing the whole app? The user should be able to return to the main form
Any help would be appreciated..
Thx.
-D
If you closed the mainform (your startup form) then you will close the whole proj . You can hide it though . For other forms , you can use Close() method .
-
Jun 27th, 2003, 02:26 PM
#3
Sleep mode
I mean use this for hiding your main form :
-
Jun 27th, 2003, 05:47 PM
#4
Thread Starter
Junior Member
But how do I show it again from another form?
-
Jun 27th, 2003, 05:51 PM
#5
Thread Starter
Junior Member
frmMain.Hide() generates an error
It says
Reference to a non-shared member requires an object reference.
-
Jun 27th, 2003, 06:29 PM
#6
PowerPoster
-
Jun 27th, 2003, 07:37 PM
#7
Sleep mode
Originally posted by Deloma
But how do I show it again from another form?
Best solution for this is to declare all your forms in a module as public like this :
VB Code:
Public frm1 As New Form1
Public frm2 As New Form2
Public frm3 As New Form3
Then you can only use different methods of each one as you're doing in VB6 . Something like this :
VB Code:
frm1.Show 'to show your form back
You really need to have a look at the link hellswraith posted , it's needed .
-
Jun 27th, 2003, 07:46 PM
#8
Thread Starter
Junior Member
Thx a lot..
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
|