[RESOLVED] VB6 - Log Out Old Application and Restart Again
Dear Experts,
I am badly stuck in a problem would appreciate if someone can help me out of this ..
I have a VB6 Application where my Login Screen appears first then the MDI Screen.
Now I need to give a Logout Button in MDI Form (one of the toolbar button); where in when clicked should display the Login Screen again after application is logged out.
The problem as you must have got an idea is when the MDI closes, entire application gets closed :confused:
Please guide how can I restart the Application or load back the Login Screen (as it has option of remembering the same computer, user and password it has to load back getting details from database each time it starts)
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
did you try load strtform, whatever the name of the start form is?
Re: VB6 - Log Out Old Application and Restart Again
yes, the problem is before loading LoginForm i need to close all form and while doing so MDIFRM also needs to close and that closes all form and the next statement where I am loading the LLoginForm never runs ..
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
This is something I was experimenting with.
In the click event of the button you want to use to to the "Login screen":
vb Code:
'unload the form
Unload Me
Main
In a module:
vb Code:
Sub Main()
Dim fLogin As New frmLogin 'Change this to the name of your login screen
fLogin.Show vbModal
If Not fLogin.OK Then
'Login Failed so exit app
End
End If
Unload fLogin
frmMain.Show 'Change this to the name of your main form
End Sub
Set the project startup object as "Sub Main".
Re: VB6 - Log Out Old Application and Restart Again
Thanks Nightwalker83 for your help; the problem with me is
1. The Application Startup has to be License form that checks the license
2. Once the License is valid then it launches the frmLogin
3. Then frmLogin success launches the MDIform & the frmMain within that
Now the MDIform has a toolbar which has EXIT button which exits the Application all is well; and if you need to login as new user then you have to exit and relaunch the application manually.
but now the they are asking to have a Logout button (that log outs the old and gives a login screen again to login) so they can re-login without going to the application and re-login.
Hope this explanation is clear enough,
Await your reply,
Best Regards
Sam
Re: VB6 - Log Out Old Application and Restart Again
What is the licensing method a form or sub main?
Re: VB6 - Log Out Old Application and Restart Again
its a form created using activelock3.6 licensing dll, which checks and allows user to use for few days after that they need to register through same form.
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
Would the code I posted in post #4 solve the problem?
Re: VB6 - Log Out Old Application and Restart Again
I am working on your concept Nightwalker83 .. lets see if it works but I doubt though ..
any other ideas are welcome .. so that I can combine them and workout something that would work :)
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
Quote:
Originally Posted by
sam4help
I am working on your concept Nightwalker83 .. lets see if it works but I doubt though ..
any other ideas are welcome .. so that I can combine them and workout something that would work :)
Best Regards,
Sam
Ah ok, although, you will need to modify it to check if the password entered is the same as the stored password. You might also, want to how a remember me option to auto fill in a persons login so they don't have to keep entering all the time.
Re: VB6 - Log Out Old Application and Restart Again
Yes I have "Remember Me" option; for which it has to reload the form as on the form loading I am fetching that details from database based on the system name.
So as I told you I need to unload all forms and then reload the frmLogin ..
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
Nightwalker83 its not working with that logic .. need to come up with something else..
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
Thanks a Lot Nightwalker83 .. finally could make it work.. thanks a lot again .. sometimes talking to someone and knowing help is there makes lot of a difference :)
As you suggested I tried calling a new instance of frmLogin and here what I did was I kept the MDIform back making toolbar visible false ..so user cannot do any other task without re-login..
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
Glad to see I could help! Did that solved the problem because judging by your last post you were thinking something else was a problem?
Re: VB6 - Log Out Old Application and Restart Again
yea thanks Nightwalker83, yes it is solved now. The last same post was published multiple times so just to remove that i need to edit that with "...." :)
Best Regards,
Sam
Re: VB6 - Log Out Old Application and Restart Again
anyway the following logic . you can also try . i have used in most of my application .
Code:
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
'check for correct password
If txtUserName = txtUserName.Tag And txtPassword = "password" Then
'place code to here to pass the
'success to the calling sub
'setting a global var is the easiest
LoginSucceeded = True
Me.Hide
Form1.Show
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub