CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: log in VB form

  1. #1
    Join Date
    Nov 2000
    Location
    IL, U.S.A.
    Posts
    218

    log in VB form

    The code for the log in VB form is this.

    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 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
    else
    MsgBox "Invalid Password, try again!", , "Login"
    txtPassword.SetFocus
    SendKeys "{Home}+{End}"
    End If
    End Sub

    private Sub Form_Load()

    End Sub




    I want to input a databbase with user names and passwords. How would I test to see if the user name and the password are in the database so the person can log in?


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: log in VB form

    In cmdOK_Click, use the following code,
    dbPW is a data control associated with the table containing user names and passwords.


    dbPW.Recordset.FindFirst "user='" + txtUser.Text + "'AND password ='" + txtPassword + "'"

    If dbPW.Recordset.NoMatch then
    oh = MsgBox("Unauthorized Login", vbCritical, "error !")
    LoginSucceeded=false
    else
    LoginSucceeded=true
    Unload frmLogin
    End If





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

Featured