Saya akan coba memberikan
source code sederhana untuk Log In. Mengapa saya katakan sederhana, karena Log
In ini bersifat permanent untuk user dan passwordnya, maksudnya nama user dan
password saya tempatkan langsung pada source code. Sehingga saat menjalankan
kan program ini, kita harus tau nama user dan password yang kita masukan di
source codenya. program ini dilengkapi dengan progressbar untuk menambah
variasi.
Baiklah gak perlu lama2, langsung
aja buat sebuah form yang terdiri dari 2 label untuk user dan password, 2
textbox juga untuk user dan password, 2 combobox untuk tombol Log In dan
Keluar, 1 timmer, dan 1 progressbar. Kemudian buat lagi 1 form yang kita
gunakan untuk form menu utama. berikut source codenya :
Private Sub Cmd_log_Click()
If Text_user = "" And Text_pass = "" Then
MsgBox ("Isi dulu User dan Passwordnya...!!!"), vbInformation, "Sory....."
Text_user.Text = ""
Text_pass.Text = ""
Text_user.SetFocus
ElseIf Text_user = "" Then
MsgBox ("Isi dulu Usernya...!!!"), vbInformation, "Sory....."
Text_user.Text = ""
Text_user.SetFocus
ElseIf Text_pass = "" Then
MsgBox ("Isi dulu Passwordnya...!!!"), vbInformation, "Sory....."
Text_pass.Text = ""
Text_pass.SetFocus
ElseIf Text_user = "ADMIN" And Text_pass = "1234" Then
MsgBox ("Selemat Datang..."), vbOKOnly, "Welcome"
Timer1.Enabled = True
ElseIf Text_user <> "ADMIN" Then
MsgBox ("User salah..!!!!"), vbInformation, "Ooops..."
Text_user.Text = ""
Text_user.SetFocus
ElseIf Text_pass <> "1234" Then
MsgBox ("Password salah..!!!!"), vbInformation, "Ooops..."
Text_pass.Text = ""
Text_pass.SetFocus
Else
MsgBox ("User dan password salah..."), vbInformation, "Ooops..."
Text_user.Text = ""
Text_pass.Text = ""
Text_user.SetFocus
End If
End Sub
Private Sub Form_Activate()
Text_user.SetFocus
End Sub
Private Sub Form_Load()
Text_user = ""
Text_pass = ""
Text_pass.PasswordChar = "*"
ProgressBar1.Min = 0
ProgressBar1.max = 1000
Timer1.Enabled = False
End Sub
Private Sub Text_pass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text_user = "" And Text_pass = "" Then
MsgBox ("Isi dulu User dan Passwordnya...!!!"), vbInformation, "Sory....."
Text_user.Text = ""
Text_pass.Text = ""
Text_user.SetFocus
ElseIf Text_user = "" Then
MsgBox ("Isi dulu Usernya...!!!"), vbInformation, "Sory....."
Text_user.Text = ""
Text_user.SetFocus
ElseIf Text_pass = "" Then
MsgBox ("Isi dulu Passwordnya...!!!"), vbInformation, "Sory....."
Text_pass.Text = ""
Text_pass.SetFocus
ElseIf Text_user = "ADMIN" And Text_pass = "1234" Then
MsgBox ("Selemat Datang..."), vbOKOnly, "Welcome"
Timer1.Enabled = True
ElseIf Text_user <> "ADMIN" Then
MsgBox ("User salah..!!!!"), vbInformation, "Ooops..."
Text_user.Text = ""
Text_user.SetFocus
ElseIf Text_pass <> "1234" Then
MsgBox ("Password salah..!!!!"), vbInformation, "Ooops..."
Text_pass.Text = ""
Text_pass.SetFocus
Else
MsgBox ("User dan password salah..."), vbInformation, "Ooops..."
Text_user.Text = ""
Text_pass.Text = ""
Text_user.SetFocus
End If
End Sub
Private Sub Form_Activate()
Text_user.SetFocus
End Sub
Private Sub Form_Load()
Text_user = ""
Text_pass = ""
Text_pass.PasswordChar = "*"
ProgressBar1.Min = 0
ProgressBar1.max = 1000
Timer1.Enabled = False
End Sub
Private Sub Text_pass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Cmd_log.SetFocus
End Sub
Private Sub Text_user_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
End Sub
Private Sub Text_user_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text_pass.SetFocus
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
For i = ProgressBar1.Min To ProgressBar1.max
ProgressBar1.Value = i
If ProgressBar1.Value = 1000 Then
Unload Me
menu.Show
End If
Next
End Sub
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
For i = ProgressBar1.Min To ProgressBar1.max
ProgressBar1.Value = i
If ProgressBar1.Value = 1000 Then
Unload Me
menu.Show
End If
Next
End Sub
Tidak ada komentar:
Posting Komentar