Logout button on main form
Logout button on main form
Logout button on main form
Logout button on main form
Logout button on main form
Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form
Logout button on main form Logout button on main form
Logout button on main form
Go Back  Xtreme Visual Basic Talk > > > Logout button on main form


Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2014, 10:32 AM
wnmichaud wnmichaud is offline
Newcomer
 
Join Date: Apr 2014
Posts: 1
Unhappy Logout button on main form


Hello Guys,

I need to logout user while closing all open forms and reopen the login form.

I did triy the following but it does not work for me:

(Main Form)
Private Sub btnLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogout.Click
LoginForm.Close()
LoginForm.Dispose()
LoginForm = Nothing

ModuleLoad.LoginForm_Load()

End Sub

(Login Form)
Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Close all the forms but Login form
For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
If My.Application.OpenForms.Item(i) IsNot Me Then
My.Application.OpenForms.Item(i).Close()
End If
Next i

Exit sub

---------------------------------------------------------------

I get an error on ModuleLoad.LoginForm_Load() stating LoginForm_Load() is not a member of System.ModuleHandle..

Problem is with Modulehandle..

I am using Visual studio 2010

I tried a number of declarations , no luck..

Guide me on this one.

Thanks
Reply With Quote
  #2  
Old 04-13-2014, 06:33 AM
Gruff's Avatar
GruffLogout button on main form Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

You have to control your program entry and exit points.
In the example below you would close all other forms on the frmMain_FormClosed or _FormClosing event.

Code:
Module modStartUp ' In your project properties uncheck 'Enable Application Framework' ' and set your startup object to 'Sub Main' Public ShutDown As Boolean = False Public Sub Main() Do ' Launch Login dialog Dim dlg As New dlgLogIn If dlg.ShowDialog = DialogResult.OK Then ' Launch Main form as a dialog Dim frm As New frmMain frm.ShowDialog() ShutDown = False ' When frmMain closes we loop back to the login. Else ShutDown = True End If Loop Until ShutDown End Sub End Module
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Logout button on main form
Logout button on main form
Logout button on main form Logout button on main form
Logout button on main form
Logout button on main form
Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form Logout button on main form
Logout button on main form
Logout button on main form
 
Logout button on main form
Logout button on main form
 
-->