All about creating login forms vb6 code.

Asked By 30 points N/A Posted on -
qa-featured

Hello techyv,

All about creating login forms vb6 code. I want to create a hotel reservation system using visual basic 6 programming language. 

I am still on the log in structure part, can you share with me some codes to make it easier for me to construct a login form?

Expecting some help from you guys.

SHARE
Best Answer by Scott Aust
Best Answer
Best Answer
Answered By 5 points N/A #165924

All about creating login forms vb6 code.

qa-featured

Hi Young,

 
Here is a sample login function for VB6.
 
Private Sub cmdLogin_Click()
     If txtUsername.Text = "" Then
           MsgBox "Invalid Username"
    ElseIf txtPassword.Text = "" Then
            MsgBox "Invalid Password"
     Else
            login
     End If
End Sub
 
Private Sub Command1_Click()
         frmExit.Visible = True
End Sub
 
Private Sub Form_Load()
    Me.Top = (Screen.Height – Me.Height) / 2
    Me.Left = (Screen.Width – Me.Width) / 2
    frmLogin.BackColor = vbWhite
    connect
    
End Sub
 
Function login()
Set rs = New ADODB.Recordset
            rs.Open "SELECT * FROM PASS", cnn
    While Not rs.EOF
        If txtPassword.Text = rs.Fields!pw And txtUsername = rs.Fields!username Then
            MsgBox "Login Successful.."
            txtPassword.Text = ""
            txtUsername.Text = ""
            frmLogin.Visible = False
            frmMain.Visible = True
                  
        Else
            If txtUsername <> rs.Fields!username Then
            MsgBox "Unregistered Username"
            txtPassword.Text = ""
            txtUsername.SetFocus
            rs.MoveNext
            Else
            MsgBox "Password Incorrect"
            txtPassword.Text = ""
            txtPassword.SetFocus
            rs.MoveNext
            End If
            
        End If
        
           
   Wend
    
End Function

Hope this helps.

 

Answered By 0 points N/A #165926

All about creating login forms vb6 code.

qa-featured

Simple Login Code for Admin user or Admin area using vb 6.0

Private Sub Command1_Click()

If Text1.Text = "admin" And Text2.Text = "admin password" Then

frmloading.Show

Else

MsgBox "INVALID username & password", vbCritical, "ERROR"

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

End Sub

Private Sub Command3_Click()

End

End Sub

(In command1_click ‘text1.text is the username and text2.text is the password’)

Command1 = login button

(In command2_click ‘text1.text is the username and text2.text is the password’)

Command2 = cancel button

Command3 = exit button

 

Answered By 0 points N/A #165925

All about creating login forms vb6 code.

qa-featured

Hi,

You can take help from daniweb go to the link software development. You have two text fields.

ID and Password. Here is the code

Private Sub txtpwd_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbEnter Then

        If Len(Trim(txtlogin)) > 0 And Len(Trim(txtpwd)) > 0 Then

            If CheckPwd(txtlogin, txtpwd) = "ok" Then

                MsgBox "Password ok"

            Else

                MsgBox "Wrong password or Login not found."

            End If

        Else

        MsgBox "Login and password should not be blank"

    End If

End If

End Sub

 

Private Function CheckPwd(cLogin As String, cPwd As String)

'in my case i will use dao. you probably using ado just convert it

Dim rs As Recordset, ret As String

Set rs = opendatabase("c:templogin.mdb").openrecordset("select * from tbllogin where ucase(trim(logname)) = '" & UCase(Trim(cLogin)) & "'")

If rs.RecordCount <> 0 Then

   If UCase(Trim(rs("pword"))) = UCase(Trim(cPwd)) Then

       ret = "ok"

   Else       ret = "wrong"

   End If

Else

 ret = "wrong"

End If

rs.Close: CheckPwd = ret

End Function

You can take help from these link

http://www.freevbcode.com/ShowCode.asp?ID=6242

This code takes input from the user as username and password and you can see that the textboxes used in the code

txtlogin and txtpwd explains it. The password will be ASCII characters and the user name used should be varchar.

Related Questions