Membuat Batas Log In
Saya akan memberikan tips memunculkan batas log in sebagai fitur tambahan pada form log ini, logikaya begini setelah sepuluh (10) kali user atau pengguna mencoba masuk dengan user name dan pasword yang salah maka munculah kolom security tambahan atau muncul suatu peringatan guna memperketat security yang telah ada, biar lebih jelas silahkan ikuti langkah langkahnya dibawah ini> Sebelumnya anda wajib mendownload form log in pada link download dibawah ini
Download - Membuat Menu Log In
> Buka file log in tadi, masukan user name dan pasword "Admin" tanpa tanda petik, jangan sampai salah ya
> Stelah berhasil Log in masuk kejendela VBE dengan menekan kombinasi tombol Alt + F11 ingat tekan Alt terlebih dahulu baru disusul dengan cepat tombol F11, ngga boleh bersamaan
> Perhatikan bagian VBAProject klik Userform1 double klik dengan cepat tombol OK lblok_Click, anda akan menemukan baris kode macro dibawah ini
Private Sub lblok_Click()
Set wsDtbsBrg = Sheets("Sheet1")
Set rgKodeBrg = wsDtbsBrg.Range("A3:A20")
Set c = rgKodeBrg.Find(txtuser.Value, LookIn:=xlValues, MatchCase:=False)
Password = c.Offset(0, 1).Value
Level = c.Offset(0, 2).Value
If txtpassword <> Password Then
MsgBox "Username atau password yang anda masukan salah"
Exit Sub
Else
MsgBox "Anda berhasil log in"
If Level = "Admin" Then
Sheets("Sheet1").Visible = xlSheetVisible
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
ElseIf Level = "User" Then
Sheets("Sheet1").Visible = xlSheetVeryHidden
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
End If
Unload Me
End If
End Sub
Set wsDtbsBrg = Sheets("Sheet1")
Set rgKodeBrg = wsDtbsBrg.Range("A3:A20")
Set c = rgKodeBrg.Find(txtuser.Value, LookIn:=xlValues, MatchCase:=False)
Password = c.Offset(0, 1).Value
Level = c.Offset(0, 2).Value
If txtpassword <> Password Then
MsgBox "Username atau password yang anda masukan salah"
Exit Sub
Else
MsgBox "Anda berhasil log in"
If Level = "Admin" Then
Sheets("Sheet1").Visible = xlSheetVisible
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
ElseIf Level = "User" Then
Sheets("Sheet1").Visible = xlSheetVeryHidden
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
End If
Unload Me
End If
End Sub
> Hapus saja semua baris kode macro diatas dan ganti dengan kode macro dibawah ini
Private Sub lblok_Click()
Set Scr = Sheets("Sheet1")
Set Akunq = Scr.Range("A3:A50")
If txtuser.Value = "" Then
Exit Sub
ElseIf txtpassword.Value = "" Then
Exit Sub
End If
For Cek = 1 To WorksheetFunction.CountA(Akunq)
If Format(txtuser.Value, "@") = Format(Scr.Cells(Cek + 2, 1).Value, "@") And _
Format(txtpassword.Value, "@") = Format(Scr.Cells(Cek + 2, 2).Value, "@") Then
MsgBox "Anda berhasil log in", , "Iparengan.com"
Unload Me
Exit Sub
End If
Next Cek
MsgBox "User name atau pasword yang anda masukkan salah", , "www.excelpro.id"
End Sub
Set Scr = Sheets("Sheet1")
Set Akunq = Scr.Range("A3:A50")
If txtuser.Value = "" Then
Exit Sub
ElseIf txtpassword.Value = "" Then
Exit Sub
End If
For Cek = 1 To WorksheetFunction.CountA(Akunq)
If Format(txtuser.Value, "@") = Format(Scr.Cells(Cek + 2, 1).Value, "@") And _
Format(txtpassword.Value, "@") = Format(Scr.Cells(Cek + 2, 2).Value, "@") Then
MsgBox "Anda berhasil log in", , "Iparengan.com"
Unload Me
Exit Sub
End If
Next Cek
MsgBox "User name atau pasword yang anda masukkan salah", , "www.excelpro.id"
End Sub
> Penggantian kode macro diatas bertujuan utuk memberikan tingkat sensitif yang lebih tinggi-
> Untuk memberikan security tambahan ketika pengguna melakukan kesalahan saat mencoba log in, tambahkan kode macro dibawah ini letakan tepat dibawah kode macro Next Cek
If Scr.Range("D3").Value = 10 Then
Scr.Range("D3").Value = 0
MsgBox "Anda telah salah sebanyak 10 kali, aplikasi akan ditutup", , "www.excelpro.id"
ThisWorkbook.Save
ThisWorkbook.Close
Exit Sub
End If
Scr.Range("D3").Value = 0
MsgBox "Anda telah salah sebanyak 10 kali, aplikasi akan ditutup", , "www.excelpro.id"
ThisWorkbook.Save
ThisWorkbook.Close
Exit Sub
End If
Silahkan ganti angka 10 dengan angka yang anda kehendaki, misalnya hanya 3 atau 5 kali
> Tambahkan lagi kode macro dibawah ini dan letakan tepat diatas kode macro For Cek = 1 To WorksheetFunction.CountA(Akunq)Scr.Range("D3").Value = Scr.Range("D3").Value + 1
> Jika kode diatas digabung semua akan menjadi seperti iniPrivate Sub lblok_Click()
Set Scr = Sheets("Sheet1")
Set Akunq = Scr.Range("A3:A50")
If txtuser.Value = "" Then
Exit Sub
ElseIf txtpassword.Value = "" Then
Exit Sub
End If
Scr.Range("D3").Value = Scr.Range("D3").Value + 1
For Cek = 1 To WorksheetFunction.CountA(Akunq)
If Format(txtuser.Value, "@") = Format(Scr.Cells(Cek + 2, 1).Value, "@") And _
Format(txtpassword.Value, "@") = Format(Scr.Cells(Cek + 2, 2).Value, "@") Then
MsgBox "Anda berhasil log in", , "www.excelpro.id"
Unload Me
If Level = "Admin" Then
Sheets("Sheet1").Visible = xlSheetVisible
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
ElseIf Level = "User" Then
Sheets("Sheet1").Visible = xlSheetVeryHidden
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
End If
Exit Sub
End If
Next Cek
If Scr.Range("D3").Value = 3 Then
Scr.Range("D3").Value = 0
MsgBox "Anda telah salah sebanyak 3 kali, aplikasi akan ditutup", , "www.excelpro.id"
ThisWorkbook.Save
ThisWorkbook.Close
Exit Sub
End If
MsgBox "User name atau pasword yang anda masukkan salah", , "www.excelpro.id"
End Sub
Set Scr = Sheets("Sheet1")
Set Akunq = Scr.Range("A3:A50")
If txtuser.Value = "" Then
Exit Sub
ElseIf txtpassword.Value = "" Then
Exit Sub
End If
Scr.Range("D3").Value = Scr.Range("D3").Value + 1
For Cek = 1 To WorksheetFunction.CountA(Akunq)
If Format(txtuser.Value, "@") = Format(Scr.Cells(Cek + 2, 1).Value, "@") And _
Format(txtpassword.Value, "@") = Format(Scr.Cells(Cek + 2, 2).Value, "@") Then
MsgBox "Anda berhasil log in", , "www.excelpro.id"
Unload Me
If Level = "Admin" Then
Sheets("Sheet1").Visible = xlSheetVisible
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
ElseIf Level = "User" Then
Sheets("Sheet1").Visible = xlSheetVeryHidden
Sheets("Sheet2").Visible = xlSheetVisible
Sheets("Sheet3").Visible = xlSheetVisible
End If
Exit Sub
End If
Next Cek
If Scr.Range("D3").Value = 3 Then
Scr.Range("D3").Value = 0
MsgBox "Anda telah salah sebanyak 3 kali, aplikasi akan ditutup", , "www.excelpro.id"
ThisWorkbook.Save
ThisWorkbook.Close
Exit Sub
End If
MsgBox "User name atau pasword yang anda masukkan salah", , "www.excelpro.id"
End Sub
> Selesai dan saatnya anda mencobanya, coba masukan user ame dan pasword secara asal biar salah kemudian ulangi sampai 10 kali maka apa yang terjadi ??
Demikianlah cara Membuat Batas Log In berbasis microsoft excel, jika anda menemukan kesulitan silahkan tulis kendala dan kesulitan yang anda temukan pada kolom komentar dibawah ini ( anda juga bisa menyisipkan gambar pada kolom komentar sebagaimana komentar di facebook), saya juga telah mengupload file sampel Membuat Batas Log In berbasis microsoft excel di Google Drive dan bisa anda download dilink download dibawah.
Download - Membuat Menu Log In
Gabung difanpage ExcelPro atau follow IG penulis Wasis Zain