VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to unload the form? Posted by swift_speed on 10 Jul 2003 at 8:05 AM
Hi
how to unload the form like Visula Basic 6 using the code unload me?
The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
Pleae help me.
Thanks!
Report
Re: How to unload the form? Posted by lrs013400 on 11 Jul 2003 at 9:57 AM
: Hi
: how to unload the form like Visula Basic 6 using the code unload me?
: The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: Pleae help me.
: Thanks!
:
Me. Close should only close the current form (not sure why that isn't happening in your case) However Me.Dispose will release all resources used by the form and close it also. I hope I understand what you are trying to do.
-Larry-
Report
Re: How to unload the form? Posted by SujathaG on 11 Jul 2003 at 10:03 AM
: Hi
: how to unload the form like Visula Basic 6 using the code unload me?
: The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: Pleae help me.
: Thanks!
:
I am having a similar problem:
PLEASE HELP!
I am having problem hiding and closing Login form:

I have two forms: Login and Main. I have a module: Module1.

In Sub Main I show Login form.
When login is successful, it loads Main form.

When the Main form is loaded, I want the login form to hide.

On Main form I have menus: Logoff and Exit.

When Logoff is clicked I want the Login form to show with New user string in its textbox.

When Exit is clicked in Main then I want to close Main and Login forms.

If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?

Code in Login form:


Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If TextBox1.Text = "Sujatha" Then
frmNewMain.ShowDialog()
Me.Close()
Else
System.Windows.Forms.MessageBox.Show("Wrong ID")
End If
End Sub

Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TextBox1.Text = "Sujatha"
End Sub

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub


Code in Main form:

Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
Me.Close()
End Sub

Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
frmNewLogin.TextBox1.Text = "dfdjk"
Me.Close()
End Sub

Code in Sub Main:

Public frmNewLogin As New frmLogin
Public frmNewMain As New frmMain
Public Sub main()
frmNewLogin.ShowDialog()
frmNewLogin = Nothing
frmNewMain = Nothing
End Sub

Report
Re: How to unload the form? Posted by lrs013400 on 11 Jul 2003 at 2:10 PM
: : Hi
: : how to unload the form like Visula Basic 6 using the code unload me?
: : The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: : Pleae help me.
: : Thanks!
: :
: I am having a similar problem:
: PLEASE HELP!
: I am having problem hiding and closing Login form:
:
: I have two forms: Login and Main. I have a module: Module1.
:
: In Sub Main I show Login form.
: When login is successful, it loads Main form.
:
: When the Main form is loaded, I want the login form to hide.
:
: On Main form I have menus: Logoff and Exit.
:
: When Logoff is clicked I want the Login form to show with New user string in its textbox.
:
: When Exit is clicked in Main then I want to close Main and Login forms.
:
: If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?
:
: Code in Login form:
:
:
: Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
: If TextBox1.Text = "Sujatha" Then
: frmNewMain.ShowDialog()
: Me.Close()
: Else
: System.Windows.Forms.MessageBox.Show("Wrong ID")
: End If
: End Sub
:
: Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: 'TextBox1.Text = "Sujatha"
: End Sub
:
: Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
: Me.Close()
: End Sub
:
:
: Code in Main form:
:
: Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
: Me.Close()
: End Sub
:
: Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
: frmNewLogin.TextBox1.Text = "dfdjk"
: Me.Close()
: End Sub
:
: Code in Sub Main:
:
: Public frmNewLogin As New frmLogin
: Public frmNewMain As New frmMain
: Public Sub main()
: frmNewLogin.ShowDialog()
: frmNewLogin = Nothing
: frmNewMain = Nothing
: End Sub
:
:
Two things, first what form starts the project? Because if that form is closed at any time, I believe the project will end. Second, you are using the ShowDialog() method to load the new form. By using ShowDialog() the focus will become the form that was just loaded, so any thing coded after that, will not excute until the form that was called is closed.
If your Login is the first form, I would try something like this when ok is clicked

'check for password blah, blah blah
Me.Hide 'Hide your login form so it is no longer visable
frmMain.ShowDialog() 'Will transfer focus to the Main form
txtbox1.Text = "Select different login" 'Will put this string in textbox
Me.Show ' Will be executed when Main is closed to re-show Login

In you Main form when Exit is clicked, use the END command to end the program. It will close everything and stop the program.
I hope this helps and that I understood what you were trying to do. If you have any other questions please ask. lrs013400@hotmail.com
Please note, I'm a newbie myself, so I'm learning as I go along.
Report
Re: How to unload the form? Posted by SujathaG on 11 Jul 2003 at 2:37 PM
: : : Hi
: : : how to unload the form like Visula Basic 6 using the code unload me?
: : : The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: : : Pleae help me.
: : : Thanks!
: : :
: : I am having a similar problem:
: : PLEASE HELP!
: : I am having problem hiding and closing Login form:
: :
: : I have two forms: Login and Main. I have a module: Module1.
: :
: : In Sub Main I show Login form.
: : When login is successful, it loads Main form.
: :
: : When the Main form is loaded, I want the login form to hide.
: :
: : On Main form I have menus: Logoff and Exit.
: :
: : When Logoff is clicked I want the Login form to show with New user string in its textbox.
: :
: : When Exit is clicked in Main then I want to close Main and Login forms.
: :
: : If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?
: :
: : Code in Login form:
: :
: :
: : Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
: : If TextBox1.Text = "Sujatha" Then
: : frmNewMain.ShowDialog()
: : Me.Close()
: : Else
: : System.Windows.Forms.MessageBox.Show("Wrong ID")
: : End If
: : End Sub
: :
: : Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : 'TextBox1.Text = "Sujatha"
: : End Sub
: :
: : Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
: : Me.Close()
: : End Sub
: :
: :
: : Code in Main form:
: :
: : Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
: : Me.Close()
: : End Sub
: :
: : Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
: : frmNewLogin.TextBox1.Text = "dfdjk"
: : Me.Close()
: : End Sub
: :
: : Code in Sub Main:
: :
: : Public frmNewLogin As New frmLogin
: : Public frmNewMain As New frmMain
: : Public Sub main()
: : frmNewLogin.ShowDialog()
: : frmNewLogin = Nothing
: : frmNewMain = Nothing
: : End Sub
: :
: :
: Two things, first what form starts the project? Because if that form is closed at any time, I believe the project will end. Second, you are using the ShowDialog() method to load the new form. By using ShowDialog() the focus will become the form that was just loaded, so any thing coded after that, will not excute until the form that was called is closed.
: If your Login is the first form, I would try something like this when ok is clicked
:
: 'check for password blah, blah blah
: Me.Hide 'Hide your login form so it is no longer visable
: frmMain.ShowDialog() 'Will transfer focus to the Main form
: txtbox1.Text = "Select different login" 'Will put this string in textbox
: Me.Show ' Will be executed when Main is closed to re-show Login
:
: In you Main form when Exit is clicked, use the END command to end the program. It will close everything and stop the program.
: I hope this helps and that I understood what you were trying to do. If you have any other questions please ask. lrs013400@hotmail.com
: Please note, I'm a newbie myself, so I'm learning as I go along.
:
Thanks for your reply.
I tried what you suggested, but I still the Login form in the taskbar.
Report
Re: How to unload the form? Posted by lrs013400 on 11 Jul 2003 at 2:44 PM
: : : : Hi
: : : : how to unload the form like Visula Basic 6 using the code unload me?
: : : : The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: : : : Pleae help me.
: : : : Thanks!
: : : :
: : : I am having a similar problem:
: : : PLEASE HELP!
: : : I am having problem hiding and closing Login form:
: : :
: : : I have two forms: Login and Main. I have a module: Module1.
: : :
: : : In Sub Main I show Login form.
: : : When login is successful, it loads Main form.
: : :
: : : When the Main form is loaded, I want the login form to hide.
: : :
: : : On Main form I have menus: Logoff and Exit.
: : :
: : : When Logoff is clicked I want the Login form to show with New user string in its textbox.
: : :
: : : When Exit is clicked in Main then I want to close Main and Login forms.
: : :
: : : If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?
: : :
: : : Code in Login form:
: : :
: : :
: : : Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
: : : If TextBox1.Text = "Sujatha" Then
: : : frmNewMain.ShowDialog()
: : : Me.Close()
: : : Else
: : : System.Windows.Forms.MessageBox.Show("Wrong ID")
: : : End If
: : : End Sub
: : :
: : : Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : : 'TextBox1.Text = "Sujatha"
: : : End Sub
: : :
: : : Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
: : : Me.Close()
: : : End Sub
: : :
: : :
: : : Code in Main form:
: : :
: : : Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
: : : Me.Close()
: : : End Sub
: : :
: : : Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
: : : frmNewLogin.TextBox1.Text = "dfdjk"
: : : Me.Close()
: : : End Sub
: : :
: : : Code in Sub Main:
: : :
: : : Public frmNewLogin As New frmLogin
: : : Public frmNewMain As New frmMain
: : : Public Sub main()
: : : frmNewLogin.ShowDialog()
: : : frmNewLogin = Nothing
: : : frmNewMain = Nothing
: : : End Sub
: : :
: : :
: : Two things, first what form starts the project? Because if that form is closed at any time, I believe the project will end. Second, you are using the ShowDialog() method to load the new form. By using ShowDialog() the focus will become the form that was just loaded, so any thing coded after that, will not excute until the form that was called is closed.
: : If your Login is the first form, I would try something like this when ok is clicked
: :
: : 'check for password blah, blah blah
: : Me.Hide 'Hide your login form so it is no longer visable
: : frmMain.ShowDialog() 'Will transfer focus to the Main form
: : txtbox1.Text = "Select different login" 'Will put this string in textbox
: : Me.Show ' Will be executed when Main is closed to re-show Login
: :
: : In you Main form when Exit is clicked, use the END command to end the program. It will close everything and stop the program.
: : I hope this helps and that I understood what you were trying to do. If you have any other questions please ask. lrs013400@hotmail.com
: : Please note, I'm a newbie myself, so I'm learning as I go along.
: :
: Thanks for your reply.
: I tried what you suggested, but I still the Login form in the taskbar.
:
You can set the property of the Login form to show in taskbar = false. It's one the properties you can set.

Report
Re: How to unload the form? Posted by SujathaG on 14 Jul 2003 at 8:55 AM
: : : : : Hi
: : : : : how to unload the form like Visula Basic 6 using the code unload me?
: : : : : The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: : : : : Pleae help me.
: : : : : Thanks!
: : : : :
: : : : I am having a similar problem:
: : : : PLEASE HELP!
: : : : I am having problem hiding and closing Login form:
: : : :
: : : : I have two forms: Login and Main. I have a module: Module1.
: : : :
: : : : In Sub Main I show Login form.
: : : : When login is successful, it loads Main form.
: : : :
: : : : When the Main form is loaded, I want the login form to hide.
: : : :
: : : : On Main form I have menus: Logoff and Exit.
: : : :
: : : : When Logoff is clicked I want the Login form to show with New user string in its textbox.
: : : :
: : : : When Exit is clicked in Main then I want to close Main and Login forms.
: : : :
: : : : If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?
: : : :
: : : : Code in Login form:
: : : :
: : : :
: : : : Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
: : : : If TextBox1.Text = "Sujatha" Then
: : : : frmNewMain.ShowDialog()
: : : : Me.Close()
: : : : Else
: : : : System.Windows.Forms.MessageBox.Show("Wrong ID")
: : : : End If
: : : : End Sub
: : : :
: : : : Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : : : 'TextBox1.Text = "Sujatha"
: : : : End Sub
: : : :
: : : : Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
: : : : Me.Close()
: : : : End Sub
: : : :
: : : :
: : : : Code in Main form:
: : : :
: : : : Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
: : : : Me.Close()
: : : : End Sub
: : : :
: : : : Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
: : : : frmNewLogin.TextBox1.Text = "dfdjk"
: : : : Me.Close()
: : : : End Sub
: : : :
: : : : Code in Sub Main:
: : : :
: : : : Public frmNewLogin As New frmLogin
: : : : Public frmNewMain As New frmMain
: : : : Public Sub main()
: : : : frmNewLogin.ShowDialog()
: : : : frmNewLogin = Nothing
: : : : frmNewMain = Nothing
: : : : End Sub
: : : :
: : : :
: : : Two things, first what form starts the project? Because if that form is closed at any time, I believe the project will end. Second, you are using the ShowDialog() method to load the new form. By using ShowDialog() the focus will become the form that was just loaded, so any thing coded after that, will not excute until the form that was called is closed.
: : : If your Login is the first form, I would try something like this when ok is clicked
: : :
: : : 'check for password blah, blah blah
: : : Me.Hide 'Hide your login form so it is no longer visable
: : : frmMain.ShowDialog() 'Will transfer focus to the Main form
: : : txtbox1.Text = "Select different login" 'Will put this string in textbox
: : : Me.Show ' Will be executed when Main is closed to re-show Login
: : :
: : : In you Main form when Exit is clicked, use the END command to end the program. It will close everything and stop the program.
: : : I hope this helps and that I understood what you were trying to do. If you have any other questions please ask. lrs013400@hotmail.com
: : : Please note, I'm a newbie myself, so I'm learning as I go along.
: : :
: : Thanks for your reply.
: : I tried what you suggested, but I still the Login form in the taskbar.
: :
: You can set the property of the Login form to show in taskbar = false. It's one the properties you can set.
:
:
GREAT! You solved my problem. Thanks.
Report
Re: How to unload the form? Posted by desrtrat17 on 4 May 2004 at 9:07 AM
: : : : : : Hi
: : : : : : how to unload the form like Visula Basic 6 using the code unload me?
: : : : : : The VB.net code me.close() will close all the forms while me.hide() cannot erase the unwanted form from the memory.
: : : : : : Pleae help me.
: : : : : : Thanks!
: : : : : :
: : : : : I am having a similar problem:
: : : : : PLEASE HELP!
: : : : : I am having problem hiding and closing Login form:
: : : : :
: : : : : I have two forms: Login and Main. I have a module: Module1.
: : : : :
: : : : : In Sub Main I show Login form.
: : : : : When login is successful, it loads Main form.
: : : : :
: : : : : When the Main form is loaded, I want the login form to hide.
: : : : :
: : : : : On Main form I have menus: Logoff and Exit.
: : : : :
: : : : : When Logoff is clicked I want the Login form to show with New user string in its textbox.
: : : : :
: : : : : When Exit is clicked in Main then I want to close Main and Login forms.
: : : : :
: : : : : If I cant do this, at least I want to close the login form as soon as login is successful and reload it. Even this I was not able to do, because in Login form, when user clicks OK, the Main form is loaded and the execution go to where it says me.close in Logins OK button. It does not go there until Main form is unloaded. How can I close Login form as soon as Main is loaded?
: : : : :
: : : : : Code in Login form:
: : : : :
: : : : :
: : : : : Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
: : : : : If TextBox1.Text = "Sujatha" Then
: : : : : frmNewMain.ShowDialog()
: : : : : Me.Close()
: : : : : Else
: : : : : System.Windows.Forms.MessageBox.Show("Wrong ID")
: : : : : End If
: : : : : End Sub
: : : : :
: : : : : Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : : : : 'TextBox1.Text = "Sujatha"
: : : : : End Sub
: : : : :
: : : : : Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
: : : : : Me.Close()
: : : : : End Sub
: : : : :
: : : : :
: : : : : Code in Main form:
: : : : :
: : : : : Private Sub mnuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuExit.Click
: : : : : Me.Close()
: : : : : End Sub
: : : : :
: : : : : Private Sub mnuLogoff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuLogoff.Click
: : : : : frmNewLogin.TextBox1.Text = "dfdjk"
: : : : : Me.Close()
: : : : : End Sub
: : : : :
: : : : : Code in Sub Main:
: : : : :
: : : : : Public frmNewLogin As New frmLogin
: : : : : Public frmNewMain As New frmMain
: : : : : Public Sub main()
: : : : : frmNewLogin.ShowDialog()
: : : : : frmNewLogin = Nothing
: : : : : frmNewMain = Nothing
: : : : : End Sub
: : : : :
: : : : :
: : : : Two things, first what form starts the project? Because if that form is closed at any time, I believe the project will end. Second, you are using the ShowDialog() method to load the new form. By using ShowDialog() the focus will become the form that was just loaded, so any thing coded after that, will not excute until the form that was called is closed.
: : : : If your Login is the first form, I would try something like this when ok is clicked
: : : :
: : : : 'check for password blah, blah blah
: : : : Me.Hide 'Hide your login form so it is no longer visable
: : : : frmMain.ShowDialog() 'Will transfer focus to the Main form
: : : : txtbox1.Text = "Select different login" 'Will put this string in textbox
: : : : Me.Show ' Will be executed when Main is closed to re-show Login
: : : :
: : : : In you Main form when Exit is clicked, use the END command to end the program. It will close everything and stop the program.
: : : : I hope this helps and that I understood what you were trying to do. If you have any other questions please ask. lrs013400@hotmail.com
: : : : Please note, I'm a newbie myself, so I'm learning as I go along.
: : : :
: : : Thanks for your reply.
: : : I tried what you suggested, but I still the Login form in the taskbar.
: : :
: : You can set the property of the Login form to show in taskbar = false. It's one the properties you can set.
: :
: :
: GREAT! You solved my problem. Thanks.
:

Report
Re: How to unload the form? Posted by desrtrat17 on 4 May 2004 at 9:09 AM
Soory i forgot to erase everything first here is the simplest code you will ever need for unloading a form Note this is for a close button, it also works for menu button you just have to change the name.

private sub cmdclose_click()
unload me
end sub
Report
Re: How to unload the form? Posted by kainsworth on 5 May 2004 at 12:55 AM

Hi desrtrat,

Don't want to burst your balloon as you are obviously just trying to be helpful to fellow members. But your code only works in VB.Old and will not compile in VB.Net - which is the language of choice in this forum.

You're right, though - it is really handy in VB.Old.

Ged

: Soory i forgot to erase everything first here is the simplest code you will ever need for unloading a form Note this is for a close button, it also works for menu button you just have to change the name.
:
: private sub cmdclose_click()
: unload me
: end sub
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.