Buka program VB, kemudian buat project dan properties seperti gambar.
![]() |
Tampilan Form1 sebelum dieksekusi |
![]() | ||
Properties untuk semua komponen pada Form1 |
![]() | |
Tampilan Form2 sebelum dieksekusi |
![]() |
Properties untuk semua komponen pada Form2 |
Private Sub Command1_Click()
If Text1.Text = "shane" And Text2.Text = "visualbasic" Then
MsgBox "ID & Password confirmation successfully!!", vbOKOnly
Unload Me
Form2.Show
Else
MsgBox "ID or Password confirmation failed. Please try again!", vbOKOnly
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
Masukkan kode berikut ke dalam kode editor form kedua.
Private Sub Command1_Click()
If Text1.Text = "shane" And Text2.Text = "visualbasic" Then
MsgBox "ID & Password confirmation successfully!!", vbOKOnly
Unload Me
Form1.Show
Else
MsgBox "ID or Password confirmation failed. Please try again!", vbOKOnly
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Catatan : Tulisan yang berwarna biru bisa diganti dengan kata apapun.
Kemudian, eksekusi program dengan menekan tombol "Start" di toolbar sehingga muncul tampilan seperti gambar berikut (jika persis dengan kode diatas).
![]() |
Tampilan program Form1 setelah memasukkan ID dan Password |
![]() | |
Tampilan messagebox setelah menekan tombol LOGIN, Klik OK! |
![]() |
Tampilan program Form2 hasil LOGIN dan setelah memasukkan ID dan Password |
![]() |
Tampilan program setelah menekan tombol LOGOUT di Form2 (kembali ke Form1) |
Jika ada permasalahan, silahkan komentarnya dibawah...
Tidak ada komentar:
Posting Komentar