Tujuan Peng-Aplikasian
Program Membuat Password Login Menggunakan Struktur Perulangan If then Else
Rancangan Tampilan Form login
Komponen | Nama | Nilai |
Form | Name | frmlogin |
Caption | ::== Login Pengguna ::=== | |
Label | Name | Label1 |
Caption | Nama Pengguna = > | |
Label | Name | Label2 |
Caption | Password = > | |
Label | Name | Label3 |
Caption | ::== Login Pengguna ::=== | |
Label | Name | Label4 |
Caption | CV. SAHABAT COURIER EXPRESS JAMBI | |
Text | Name | Text1 |
Text | - | |
Text | Name | Text2 |
Text | - | |
Line | Name | Line1 |
Command | Name | Command1 |
Caption | &Ok | |
Command | Name | Command2 |
Interval | &Keluar | |
Timer | Name | Timer2 |
Interval | 200 |
Listing Kode Program'membuat suatu variabel
Dim ket As String
Dim x As Integer
'perintah pada command 1
Private Sub Command1_Click()
'jika passwod benar
If (Text1.Text = "admin" And Text2.Text = "12345") Then
MsgBox "Password Benar , Silahkan Login ", vbInformation + vbOKOnly, "Sucses "
frmmenu.Show
frmlogin.Hide
'jika password salah
Else
Text1.Text = ""
pesan = MsgBox("Masukkan dulu Nama Pengguna", vbCritical + vbOKCancel, "Warning")
Text1.SetFocus
Text2.Text = ""
pesan = MsgBox("Masukkan Dulu Passwordnya", vbCritical + vbOKCancel, "WARNING")
Text2.SetFocus
If Text1.Text = "" Then
MsgBox "Masukkan Nama Pengguna Dulu"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
ElseIf Text2.Text = "" Then
MsgBox "masukkan Paswordnya dulu"
Text1.Text = ""
Text2.Text = ""
Text2.SetFocus
End If
End If
End Sub
'Perintah Keluar
Private Sub Command2_Click()
End
End Sub
'Meng-load form waktu dijalankan
Private Sub Form_Load()
x = 1
ket = ""
End Sub
'jika image 1 diklik maka akan muncul bantuan
Private Sub Image1_Click()
MsgBox "Masukkan Login Pengguna : -admin- dan Password -12345- ", vbInformation + vbOKOnly, "Good Luck "
End Sub
'jika text1 di enter kebawah
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
'timer bekerja untuk membuat tulisan berjalan pada title form
Private Sub Timer1_Timer()
ket = ket & Mid(Label3.Caption, x, 1)
frmlogin.Caption = ket
If n = Len(Label3.Caption) Then
ket = ""
x = 1
Else
x = x + 1
End If
End Sub
Jalankan Program ,Jika Berhasil login maka sucses login :
Tugas Pada Modul 2 :
- Kreasikan Form Login anda dengan menambahkan animasi Progressbar
Salam Kenal AMCJ