Assalamualaikum dan salam Sejahtera..Dah lama senyap sunyi...Malam ni kita akan belajar cara buat Log In untuk Excel menggunakan VBA
Sebelum kita mulakan pelajaran malam ni pastikan anda telah buka fail excel dan aktifkan Menu Developer
Dengan menggunakan fungsi LABEL, TextBox dan CommandButton, sila design frame anda ikut kreativiti masing-masing
Private Sub CommandButton1_Click()
Dim Username, password As String
Username = TextBox1.Text
password = TextBox2.Text
If Username = "admin" And password = "admin" Then
MsgBox "You entered the CORRECT info", vbInformation
Unload Me
Else
MsgBox "You entered the WRONG info", vbCritical
ActiveWorkbook.Close False
End If
End Sub
Dim Username, password As String
Username = TextBox1.Text
password = TextBox2.Text
If Username = "admin" And password = "admin" Then
MsgBox "You entered the CORRECT info", vbInformation
Unload Me
Else
MsgBox "You entered the WRONG info", vbCritical
ActiveWorkbook.Close False
End If
End Sub
Private Sub Workbook_Open()
Application.Visible = False
UserForm1.Show
End Sub
Application.Visible = False
UserForm1.Show
End Sub
P/S anda boleh tukar username dan password pada coding pertama tadi "admin" (tukar yang dalam" " sahaja)