: : : : : : 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.
: