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.
All about creating login forms vb6 code.
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.
Â
All about creating login forms vb6 code.
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
Â
All about creating login forms vb6 code.
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.