Kamis, 19 April 2012
Tugas VB 6 bag.2
Source Code :
Dim list As ListItem
Private Sub cmd_clear_Click()
If ListView1.ListItems.Count > 0 Then
ListView1.ListItems.Clear
End If
End Sub
Private Sub cmd_remove_Click()
ListView1.ListItems.Remove (Me.ListView1.SelectedItem.Index)
End Sub
Private Sub cmd_simpan_Click()
Set list = Me.ListView1.ListItems.Add(, , Text1.Text)
list.SubItems(1) = Me.Text2.Text
list.SubItems(2) = Me.Text3.Text
list.SubItems(3) = Me.Text4.Text
list.SubItems(4) = Me.Text5.Text
list.SubItems(5) = Me.Text6.Text
list.SubItems(6) = Me.Text7.Text
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
cmd_simpan.Enabled = False
cmd_tambah.Enabled = True
cmd_tambah.SetFocus
End Sub
Private Sub cmd_tambah_Click()
Text1.Enabled = True
cmd_simpan.Enabled = True
Text1.SetFocus
cmd_tambah.Enabled = False
End Sub
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)
If ListView1.ListItems.Count > 0 Then
cmd_clear.Enabled = True
cmd_remove.Enabled = True
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text1.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text2.Enabled = True
Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text2 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text2.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text3.Enabled = True
Text3.SetFocus
End If
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text3 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text3.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text4.Enabled = True
Text4.SetFocus
End If
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text4 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text4.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text5.Enabled = True
Text5.SetFocus
End If
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text5 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text5.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text6.Enabled = True
Text6.SetFocus
End If
End If
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text6 = "" Then
a = MsgBox("Kode Customer masih kosong", vbInformation + vbOKCancel, " ")
If a = vbOK Then
Text6.SetFocus
Else
b = MsgBox("Apakah anda ingin keluar", vbQuestion + vbYesNo, " ")
If b = vbYes Then
End
Else
Text1.SetFocus
End If
End If
Else
Text7.Enabled = True
Text7.SetFocus
End If
End If
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmd_simpan.SetFocus
End If
End Sub
Download File
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar