Sekarang saya akan sedikit share bagaimana menampilkan form perkenalan di vb 6.
1. Desain form seperti gambar di bawah ini :
Terus copy pastekan code di bawah ini :
Dim Data As Data_DiriPrivate Type Data_Dirinama As String * 30telp As String * 20email As String * 20alamat As String * 50kota As String * 20jenis As Stringhobi As String * 20End TypeSub Isi_Data()Data.nama = Txtnama.TextData.telp = Txttelp.TextData.email = Txtemail.TextData.alamat = Txtalamat.TextData.kota = Txtkota.TextData.jenis = cmbjenis.TextData.hobi = Txthobi.TextEnd Sub
Sub Tampil_Data()MsgBox "PERKENALKAN !" & Chr(10) & _ "Nama : " & Data.nama & Chr(10) & _ "No. Telp : " & Data.telp & Chr(10) & _ "Jenis Kelamin : " & Data.jenis & Chr(10) & _ "Email : " & Data.email & Chr(10) & _ "Alamat : " & Data.alamat & Chr(10) & _ "Kota : " & Data.kota & Chr(10) & _ "Hobi : " & Data.hobi & Chr(10), vbInformation, "Salam Kenal"
End Sub
Private Sub cmbjenis_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtemail.SetFocusEnd IfEnd Sub
Private Sub cmdclear_Click()Dim a As ControlFor Each a In ControlsIf TypeOf a Is TextBox Thena = ""End IfNext aEnd Sub
Private Sub Cmdexit_Click()If MsgBox("Apakah yakin ingin keluar ?", vbOKCancel, "Konfirmasi ! ") = vbOK ThenEndElseMsgBox "Silahkan Kembali ! ", , "Good"End IfEnd Sub
Private Sub Cmdmessage_Click()If Txtnama.Text = "" ThenMsgBox "Nama kosong"Txtnama.SetFocusElseIf Txttelp.Text = "" ThenMsgBox "No. telp kosong"Txttelp.SetFocusElseIf cmbjenis.Text = "" ThenMsgBox "Jenis Kelamin kosong"cmbjenis.SetFocusElseIf Txtemail.Text = "" ThenMsgBox "Email kosong"Txtemail.SetFocusElseIf Txtalamat.Text = "" ThenMsgBox "Alamat kosong"Txtalamat.SetFocusElseIf Txtkota.Text = "" ThenMsgBox "Kota kosong"Txtkota.SetFocusElseIf Txthobi.Text = "" ThenMsgBox "Hobi kosong"Txthobi.SetFocusElseCall Isi_DataCall Tampil_DataEnd IfEnd Sub
Private Sub Form_Activate()Txtnama.SetFocusEnd Sub
Private Sub Txtalamat_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtkota.SetFocusEnd IfEnd Sub
Private Sub Txtemail_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxtalamat.SetFocusEnd IfEnd Sub
Private Sub Txthobi_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCmdmessage.SetFocusEnd IfEnd Sub
Private Sub Txtkota_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxthobi.SetFocusEnd IfEnd Sub
Private Sub Txtnama_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenTxttelp.SetFocusEnd IfEnd Sub
Private Sub Txttelp_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Thencmbjenis.SetFocusEnd IfEnd Sub
Dan jika di jalankan seperti ini :
mudah bukan !!
jika ingin download filenya klik
disini !
pass :
genre-it