Di dalam Visual Basic kita bisa membuat form Login untuk masuk ke program menngunakan password.
disini akan di contohkan dengan sederhana.
Sekarang kita buat form sederhana seperti ini
Ketik coding berikut di form 1
Private Sub Command1_Click()
If Text1.Text = "allovean" Then
MDIForm1.Show
ElseIf Text1.Text = "" Then
MsgBox ("Insert Password!!!")
Text1.SetFocus
Text1.Text = ""
Else: MsgBox ("Sorry,,,Password Failed")
Text1.SetFocus
Text1.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Text1.Text = "allovean" Then
MDIForm1.Show
ElseIf KeyAscii = 13 And Text1.Text = "" Then
MsgBox ("Insert Password!!!")
Text1.SetFocus
Text1.Text = ""
ElseIf keyscii = 13 And Text1.Text <> "allovean" Then
MsgBox ("Sorry,,,Password Failed")
Text1.SetFocus
Text1.Text = ""
End If
End Sub
Selanjutnya kita buat rancang form MDI
Setelah di jalankan akan seperti ini
Setelah kita klik ok atau tekan enter maka akan tampil seperti ini








