1
Private Sub LoginMasuk_Click()
Dim Password As String 
Dim Level As String
Dim pass As String  

pass = MD5(TextBox2.Value) 
Set WsUserName = Sheets("Data")
Set RgUserPas = WsUserName.Range("A2:A20")
Set c = RgUserPas.Find(TextBox1.Value, LookIn:=xlValues, MatchCase:=False)

Password = c.Offset(0, 1).Value
Level = c.Offset(0, 2).Value 

If pass <> Password Then
    MsgBox "password yang anda masukan salah", vbCritical, "User Login"
    Exit SubElse
    If Level = "Admin" Then
        MsgBox "Selamat Datang " & TextBox1.text, vbInformation, "Message"
        'MsgBox "Anda Login Sebagai " & Level, vbInformation, "User Login"
            loginApp.Hide
                Sheets("Data").Visible = xlSheetVisible
                Sheets("Hai").Visible = xlSheetVisible
                Sheets("Halo").Visible = xlSheetVisible
            Menu_Admin.Label1.Caption = Level
            Menu_Admin.Show
        Call bersih
        Exit Sub
    ElseIf Level = "Siswa" Then
        MsgBox "Selamat Datang " & TextBox1.text, vbInformation, "Message"
        'MsgBox "Anda Login Sebagai " & Level, vbInformation, "User Login"
            loginApp.Hide
                Sheets("Data").Visible = xlSheetVeryHidden
                'Sheets("Data").Visible = xlSheetVisible
                Sheets("Hai").Visible = xlSheetVisible
                Sheets("Halo").Visible = xlSheetVisible
                Menu_Siswa.Label1.Caption = Level
                Menu_Siswa.Show
        Call bersih
        Exit Sub
    End If
End If
End Sub

and I getting error in code -->

Password = c.Offset(0, 1).Value

how i solve it

0

1 Answer 1

1

Check to see if your .Find call actually found something first. Put this before that line:

If c Is Nothing Then
  Msgbox "'" & TextBox1.Value & "' was not found"
  Exit Sub
End If
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.