Results 1 to 16 of 16

Thread: [RESOLVED] VB6 - Log Out Old Application and Restart Again

  1. #1
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,528

    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

  3. #3
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  4. #4
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,736

    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:
    1. 'unload the form
    2.      Unload Me
    3.     Main

    In a module:

    vb Code:
    1. Sub Main()
    2.     Dim fLogin As New frmLogin 'Change this to the name of your login screen
    3.     fLogin.Show vbModal
    4.     If Not fLogin.OK Then
    5.         'Login Failed so exit app
    6.         End
    7.     End If
    8.     Unload fLogin
    9.     frmMain.Show 'Change this to the name of your main form
    10. End Sub

    Set the project startup object as "Sub Main".
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  5. #5
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  6. #6
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,736

    Re: VB6 - Log Out Old Application and Restart Again

    What is the licensing method a form or sub main?
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  7. #7
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  8. #8
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,736

    Re: VB6 - Log Out Old Application and Restart Again

    Would the code I posted in post #4 solve the problem?
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  9. #9
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  10. #10
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,736

    Re: VB6 - Log Out Old Application and Restart Again

    Quote Originally Posted by sam4help View Post
    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.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  11. #11
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  12. #12
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  13. #13
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  14. #14
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,736

    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?
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  15. #15
    Lively Member
    Join Date
    Mar 12
    Posts
    91

    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

  16. #16
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,431

    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
  •