|
-
Aug 19th, 2012, 11:25 AM
#1
Thread Starter
Lively Member
[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 
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
-
Aug 19th, 2012, 04:19 PM
#2
Re: VB6 - Log Out Old Application and Restart Again
did you try load strtform, whatever the name of the start form is?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 20th, 2012, 03:35 AM
#3
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 04:11 AM
#4
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".
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 20th, 2012, 04:23 AM
#5
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 04:34 AM
#6
Re: VB6 - Log Out Old Application and Restart Again
What is the licensing method a form or sub main?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 20th, 2012, 04:36 AM
#7
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 04:57 AM
#8
Re: VB6 - Log Out Old Application and Restart Again
Would the code I posted in post #4 solve the problem?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 20th, 2012, 05:08 AM
#9
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 05:13 AM
#10
Re: VB6 - Log Out Old Application and Restart Again
 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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 20th, 2012, 05:17 AM
#11
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 06:17 AM
#12
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 07:21 AM
#13
Thread Starter
Lively Member
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
-
Aug 20th, 2012, 08:39 PM
#14
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 20th, 2012, 11:38 PM
#15
Thread Starter
Lively Member
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
-
Aug 21st, 2012, 07:56 PM
#16
Frenzied Member
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
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
|