Lalu masukkan script di bawah ini :
Private Sub cmdKeluar_Click()
ThisWorkbook.Close
End Sub
ThisWorkbook.Close
End Sub
Private Sub cmdOK_Click()
If TextBox1.Value = "" Then
MsgBox "Isi Username terlebih dulu", _
vbOKOnly + vbInformation, "User Kosong"
TextBox1.SetFocus
Exit Sub
ElseIf TextBox2.Value = "" Then
MsgBox "Isi Password terlebih dulu", _
vbOKOnly + vbInformation, "User Kosong"
TextBox2.SetFocus
Exit Sub
End If
Sheets("Sheet1").Select
If Range("d1") = False Then
LoginSalah = MsgBox("Username atau Password salah" _
& vbCrLf & "Coba masuk lagi?", _
vbYesNo + vbInformation, "Error Masuk")
'Jika tombol Yes yang di-klik
If LoginSalah = vbYes Then
'TextBox User dikosongkan
TextBox1.Value = ""
'TextBox Password dikosongkan
TextBox2.Value = ""
'TextBox User menjadi fokus
TextBox1.SetFocus
ElseIf LoginSalah = vbNo Then
Unload Me
End If
'Jika user dan password yang dimasukkan benar
Else
'Keluar dari Form Login
Unload Me
'Menampilkan kotak pesan login berhasil
MsgBox "User dan Password benar", _
vbOKOnly + vbInformation, "Login Berhasil"
End If
End Sub
If TextBox1.Value = "" Then
MsgBox "Isi Username terlebih dulu", _
vbOKOnly + vbInformation, "User Kosong"
TextBox1.SetFocus
Exit Sub
ElseIf TextBox2.Value = "" Then
MsgBox "Isi Password terlebih dulu", _
vbOKOnly + vbInformation, "User Kosong"
TextBox2.SetFocus
Exit Sub
End If
Sheets("Sheet1").Select
If Range("d1") = False Then
LoginSalah = MsgBox("Username atau Password salah" _
& vbCrLf & "Coba masuk lagi?", _
vbYesNo + vbInformation, "Error Masuk")
'Jika tombol Yes yang di-klik
If LoginSalah = vbYes Then
'TextBox User dikosongkan
TextBox1.Value = ""
'TextBox Password dikosongkan
TextBox2.Value = ""
'TextBox User menjadi fokus
TextBox1.SetFocus
ElseIf LoginSalah = vbNo Then
Unload Me
End If
'Jika user dan password yang dimasukkan benar
Else
'Keluar dari Form Login
Unload Me
'Menampilkan kotak pesan login berhasil
MsgBox "User dan Password benar", _
vbOKOnly + vbInformation, "Login Berhasil"
End If
End Sub
Private Sub TextBox1_Change()
Sheets("Sheet1").Select
Range("b1") = TextBox1
End Sub
Private Sub TextBox2_Change()
Sheets("Sheet1").Select
Range("b2") = TextBox2
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> 1 Then Cancel = True
End Sub
Pada sheet1 Cell A1 tulis "Usernamenya" dan Cell A2 tulis "Passwordnya"Sheets("Sheet1").Select
Range("b1") = TextBox1
End Sub
Private Sub TextBox2_Change()
Sheets("Sheet1").Select
Range("b2") = TextBox2
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> 1 Then Cancel = True
End Sub
Pada Cell C1 tulis rumus " =EXACT(A1;B1)" tanpa tanda petik
Pada Cell C2 tulis rumus " =EXACT(A2;B2)" tanpa tanda petik
Lalu pada Cell D1 tulis rumus " =IF(C1=FALSE;FALSE;TRUE)*IF(C2=FALSE;FALSE;TRUE) "
Semoga berhasil cara buat Form Login
Salam
3 comments
cara donlodnya gimanaya?
alamat emailnya mana ya, klo ada wkt aku kirim
mantap, cara nerapin ke aplikasi kita gimana, mohon bantuanya, email= muhammadkhotimulanwar20@yahoo.com