Senin, 26 November 2012

Memanfaatkan Array 1 Dimensi dan Array Multi Dimensi Pada VB.Net 2010



Khem.... hehehe

Kali ini IT Sasak akan berbagi sedikit pengetahuan tentang VB.Net...

Membuat aplikasi sederhana dengan memanfaatkan Array 1 Dimensi dan Multi Dimensi... ^_^


Berikut Source Codenya:
Ini source untuk Form Loadnya:

Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim Arr(4, 1) As String

Arr(0, 0) = "Kode Barang"
Arr(0, 1) = "Nama Barang"
Arr(1, 0) = "Jenis"
Arr(1, 1) = "Satuan"
Arr(2, 0) = "Sabun Mandi"
Arr(2, 1) = "Pasta Gigi"
Arr(3, 0) = "Pcs"
Arr(3, 1) = "Box"
Arr(4, 0) = "Lusin"
Arr(4, 1) = "Kodi"

ListView1.GridLines = True
ListView1.View = View.Details

For Baris = 0 To 1
For Kolom = 0 To 1
ListView1.Columns.Add(Arr(Baris, Kolom), 100)
Next Kolom
Next Baris
For Baris = 2 To 2
For Kolom = 0 To 1
cmbjenis.Items.Add(Arr(Baris, Kolom))
Next Kolom
Next Baris

For Baris = 3 To 4
For Kolom = 0 To 1
cmbsatuan.Items.Add(Arr(Baris, Kolom))
Next Kolom
Next Baris
End Sub

Sedangkan untuk source simpan (Button Simpannya):

Private Sub btnsimpan_Click(sender As System.Object, e As System.EventArgs) Handles btnsimpan.Click
Dim Arr(4) As String

Arr(1) = txtkode.Text
Arr(2) = txtnama.Text
Arr(3) = cmbjenis.Text
Arr(4) = cmbsatuan.Text

Dim listitem As ListViewItem
listitem = New ListViewItem

listitem = ListView1.Items.Add(Arr(1))
listitem.SubItems.Add(Arr(2))
listitem.SubItems.Add(Arr(3))
listitem.SubItems.Add(Arr(4))

txtkode.Text = txtkode.Text + 1
txtnama.Text = ""
cmbsatuan.Text = ""
txtnama.Focus()




End Sub

Tidak ada komentar:

Poskan Komentar

 

Design By:
SkinCorner