Buat Program yang outputnya seperti gambar
Listing programnya:
Public Class Form1
Dim listtxt(3) As String ' pendeklarasian variable
Dim listitem As ListViewItem
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'memasukkan nilai ke variabel array
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(TextBox2.Text)
listtxt(2) = Trim(TextBox3.Text)
'utk memasukkan ke listview dari variable array
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End Sub
'setting kolom listview
Sub setlistview()
ListView1.View = View.Details
'utk menetukan kolom
ListView1.Columns.Add("NPM", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama", 200, HorizontalAlignment.Center)
ListView1.Columns.Add("Alamat", 250, HorizontalAlignment.Center)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call setlistview()'memanggil procedure
End Sub
Private Sub ListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
TextBox4.Text = e.Item.Text
'untuk memasukkan nilai kolom pertama ke dalam texbox4
End Sub
End Class
Listbox
Buat tampilan seperti ini:
souce code:
Public Class Form2
Sub pros3()
ListBox1.Items.Add(TextBox3.Text + " " + TextBox4.Text + " " + TextBox5.Text + " " + TextBox6.Text + " " + TextBox7.Text)
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox4.Focus()
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
TextBox5.Focus()
End If
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If e.KeyChar = Chr(13) Then
TextBox6.Focus()
End If
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
If e.KeyChar = Chr(13) Then
TextBox7.Focus()
End If
End Sub
Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
If e.KeyChar = Chr(13) Then
Call pros3()
Call bersihpros()
TextBox3.Focus()
End If
End Sub
Sub bersihpros()
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
Tidak ada komentar:
Posting Komentar