Untuk tambah data saya mengunakan perulangan For next
OBJEK
|
PROPERTIES
|
VALUE
|
FORM
|
name
|
Frmlistbox2
|
Caption
|
ListBox2
|
|
BorderStyle
|
1-fixed single
|
|
StartUpPosition
|
centerscreen
|
|
Label1
|
name
|
Label1
|
caption
|
Jumlah Item
|
|
Frame1
|
name
|
Frame1
|
Caption
|
Data Sumber
|
|
Frame2
|
name
|
Frame2
|
Caption
|
Pilihan
|
|
Frame3
|
Name
|
Frame3
|
Caption
|
Tambah Data Untuk Data Sumber
|
|
Textbox1
|
name
|
txtjum
|
Combobox1
|
name
|
cmbItem
|
Listbox1
|
name
|
lstSumber
|
Listboxt2
|
name
|
lstpilih
|
Command1
|
name
|
cmdAddKiri
|
caption
|
>
|
|
Command2
|
name
|
cmdAddKanan
|
caption
|
<
|
|
Command3
|
Name
|
cmdAllKiri
|
Caption
|
>>
|
|
Command4
|
Name
|
cmdAllKanan
|
Caption
|
<<
|
|
Command5
|
Name
|
cmdAdd
|
Caption
|
Tambah
|
|
Command6
|
Name
|
cmdKeluar
|
caption
|
Keluar
|
Kode Program :
Private Sub
cmdKeluar_Click()
End
End Sub
Private Sub
cmbItem_Click()
lstSumber.AddItem
cmbItem.Text
'cmbItem.RemoveItem
cmbItem.ListIndex
End Sub
Private Sub
cmdAdd_Click()
If
txtJum.Text = "" Then
MsgBox "Jumlah Item Harus di Isi",
vbOKOnly + vbExclamation, "Peringatan"
txtJum.SetFocus
Else
For i = 1 To
txtJum.Text
Number = InputBox("Masukan Nama Item ke
-" & i & "", "Input data")
If Number = "" Then
Exit Sub
End If
cmbItem.AddItem Number
Next i
txtJum.Text
= Clear
End If
End Sub
Private Sub
cmdAddKanan_Click()
If
lstPilih.ListIndex < 0 Then
MsgBox "Data Tidak
diPilih/Kosong", vbOKOnly + vbInformation, "Validasi"
txtJum.SetFocus
Else
lstSumber.AddItem lstPilih.Text
lstPilih.RemoveItem lstPilih.ListIndex
End If
End Sub
Private Sub
cmdAddKiri_Click()
If
lstSumber.ListIndex < 0 Then
MsgBox "Data Tidak
Dipilih/Kosong", vbOKOnly + vbInformation, "Validasi"
txtJum.SetFocus
Else
lstPilih.AddItem lstSumber.Text
lstSumber.RemoveItem lstSumber.ListIndex
End If
End Sub
Private Sub
cmdAllKanan_Click()
If
lstPilih.ListCount < 1 Then
MsgBox "Data Pilihan Kosong",
vbOKOnly + vbExclamation, "Validasi"
txtJum.SetFocus
Else
For i = 0 To lstPilih.ListCount - 1
lstSumber.AddItem lstPilih.List(i)
Next i
lstPilih.Clear
End If
End Sub
Private Sub
cmdAllKiri_Click()
If
lstSumber.ListCount < 1 Then
MsgBox "Data Sumber Kosong",
vbOKOnly + vbExclamation, "Validasi"
txtJum.SetFocus
Else
For i = 0 To lstSumber.ListCount - 1
lstPilih.AddItem lstSumber.List(i)
Next i
lstSumber.Clear
End If
End Sub
Private Sub
Form_Activate()
txtJum.SetFocus
End Sub
Private Sub
Form_Load()
lstSumber.AddItem
"Data Satu"
lstSumber.AddItem
"Data Dua"
lstSumber.AddItem
"Data Tiga"
lstSumber.AddItem
"Data Empat"
End Sub
Private Sub
txtJum_KeyPress(KeyAscii As Integer)
If KeyAscii
= 13 Then
cmdAdd.SetFocus
End If
If Not
(KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or
KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace Or
KeyAscii = vbKeyReturn) Then
MsgBox
"Maaf Hanya Boleh Diisi Angka Saja", vbInformation + vbOKOnly,
"Perhatian"
KeyAscii = 0
End If
End Sub
Untuk teman2 yang ingin sewa hosting atau beli domain bisa disini iya : Link
dan gunakan Kode Kupon Berikut : YBNBLOG20 untuk mendapatkan potongan 5%
*KEJUJURAN ADALAH KEBIJAKSANAAN YANG PALING BAIK *
0 Comments