首页 > 解决方案 > 当我只使用数字作为密码时,它不会被检测到

问题描述

I created an account to the database with a password which only consists of numbers, and when I try to log in using that account the system rejects and displays the message box "Sorry, the password you entered is wrong!".

which means that if I create an account in the database using only numeric passwords, it will not be detected as the correct password.

I really appreciate the person who can correct my coding error.

Private Sub BTLogin_Click()
    If txtusername.Value = "" Or txtpass.Value = "" Then
        MsgBox "Username / Password cannot be empty!", vbExclamation, "Warning"
        txtusername.SetFocus
    Else
        Dim iRow As Long
        Dim Ws As Worksheet
        Set Ws = Worksheets("Administrator")
        iRow = Ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
                 If WorksheetFunction.CountIf(Ws.Range("A3", Ws.Cells(iRow - 1, 3)), Me.txtusername.Value) > 0 Then
                      Nomor = Trim(Me.txtusername.Value)
                      With Sheets("Administrator")
                                Baris = .Columns("A").Find(Nomor).Row
                                PasswordUser = Range("B" & Baris).Value
                       End With
                       If txtpass.Value <> PasswordUser Then
                           MsgBox "Sorry, the password you entered is wrong!", vbCritical, "Error"
                           txtpass.Text = ""
                           txtpass.SetFocus
                       Else
                           MsgBox "Login Success", vbInformation, "Success"
                           Unload Me
                           Application.Visible = True
                       End If
                 Else
                       MsgBox "User not registered. Please contact the administrator", vbCritical, "Warning"
                       txtusername.Text = ""
                       txtpass.Text = ""
                       txtusername.SetFocus
                   Exit Sub
                   End If
    End If
End Sub

enter image description here

标签: excelvba

解决方案


推荐阅读