3 June 2012

Tugas1 " Form Perkenalan "

 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_Diri
Private Type Data_Diri
nama As String * 30
telp As String * 20
email As String * 20
alamat As String * 50
kota As String * 20
jenis As String
hobi As String * 20
End Type
Sub Isi_Data()
Data.nama = Txtnama.Text
Data.telp = Txttelp.Text
Data.email = Txtemail.Text
Data.alamat = Txtalamat.Text
Data.kota = Txtkota.Text
Data.jenis = cmbjenis.Text
Data.hobi = Txthobi.Text
End 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 Then
Txtemail.SetFocus
End If
End Sub



Private Sub cmdclear_Click()
Dim a As Control
For Each a In Controls
If TypeOf a Is TextBox Then
a = ""
End If
Next a
End Sub

Private Sub Cmdexit_Click()
If MsgBox("Apakah yakin ingin keluar ?", vbOKCancel, "Konfirmasi ! ") = vbOK Then
End
Else
MsgBox "Silahkan Kembali ! ", , "Good"
End If
End Sub

Private Sub Cmdmessage_Click()
If Txtnama.Text = "" Then
MsgBox "Nama kosong"
Txtnama.SetFocus
ElseIf Txttelp.Text = "" Then
MsgBox "No. telp kosong"
Txttelp.SetFocus
ElseIf cmbjenis.Text = "" Then
MsgBox "Jenis Kelamin kosong"
cmbjenis.SetFocus
ElseIf Txtemail.Text = "" Then
MsgBox "Email kosong"
Txtemail.SetFocus
ElseIf Txtalamat.Text = "" Then
MsgBox "Alamat kosong"
Txtalamat.SetFocus
ElseIf Txtkota.Text = "" Then
MsgBox "Kota kosong"
Txtkota.SetFocus
ElseIf Txthobi.Text = "" Then
MsgBox "Hobi kosong"
Txthobi.SetFocus
Else
Call Isi_Data
Call Tampil_Data
End If
End Sub

Private Sub Form_Activate()
Txtnama.SetFocus
End Sub

Private Sub Txtalamat_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Txtkota.SetFocus
End If
End Sub

Private Sub Txtemail_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Txtalamat.SetFocus
End If
End Sub

Private Sub Txthobi_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Cmdmessage.SetFocus
End If
End Sub

Private Sub Txtkota_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Txthobi.SetFocus
End If
End Sub

Private Sub Txtnama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Txttelp.SetFocus
End If
End Sub

Private Sub Txttelp_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmbjenis.SetFocus
End If
End Sub


Dan jika di jalankan seperti ini :





















mudah bukan !!
jika ingin download filenya klik disini !
pass : genre-it

0 komentar:

Post a Comment