Results 1 to 4 of 4

Thread: Login Form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    17

    Login Form

    Hi,

    In my application, I have given the user the option of using a login form in order to password protect his application, if he chooses to use the form, then a simple login form pops up right after the splash screen and asks for a password, if he answers the right password then the main form opens up...
    My problem is that I set the mainform as my startup form and in the load event I set it to check wether the user checked the option (the boolean is stored in the database) for the login form, if he did then the login form pops up asking for a password, everything works fine until he presses cancel, I set it to close the main form and the login form as soon as he presses cancel but for some reason the main form still executes the remaining code in the load event, which i do not want, is there no way to tell vb that as soon as he presses cancel in the login form to immediately close the application instead of having continue the loading of the main form?

    Code:
         
    If settingsDataSet.settings.Rows(0)(20).ToString = "true" Then
    Login.ShowDialog()
    if Login.Verify = false then
    me.close()
    else 'Continue LOAD Code in Main Form

  2. #2
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Login Form

    In your login form, when the user clicks on the cancel key your code should look something like this:

    Code:
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    
        Me.Close()
        frmMainForm.Close()
    
    End Sub
    So when the user clicks on the cancel button, the logon screen and the main form both close.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    17

    Re: Login Form

    Thanks for the reply,

    I've tried doing the me.close and mainFrm.close in the cancel button but it still runs all the code after the login.showdialog() in the mainform. I think it's because once I close the Login form it automatically goes back to the mainform and runs all the code after the login.showdialog() even if the form has been closed from the login form. How can the mainform still run even after I've closed from another form.

    If I put me.close as the first thing in the LOAD event of the mainform, it still loads everything after the me.close, how can that be possible?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Login Form

    If you check on the documentation for .ShowDialog, you'll see that it returns a type DialogResult. If you have your form return the appropriate value (OK or Cancel), then you can use an if statement....

    Code:
    If Login.ShowDialog() = DialogResult.OK Then
      'Continue with the load stuff
    Else
      Me.Close
    End If
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width