Contoh Form Penggunaan di ListBox pada PemrogramanVisual(.Net)
Public Class latihanForm1
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call isicombo()
Call isibersih()
End Sub
Sub isicombo()
ComboBox1.Items.Add("06 Teknik Informatika")
ComboBox1.Items.Add("07 Sistem Informasi")
ComboBox1.Items.Add("26 Manajemen Informatika")
ComboBox1.Items.Add("67 Komputer Akuntansi")
ComboBox1.Items.Add("05 Teknik Komputer")
End Sub
Sub isibersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
ComboBox1.Text = "06 Teknik Informatika"
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Tambah" Then
Button1.Text = "Ok"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
TextBox1.Focus()
Else
ListBox1.Items.Add(Trim(TextBox1.Text) + " " + Trim(TextBox2.Text) + " " + Trim(TextBox3.Text) + " " + Trim(TextBox4.Text) + " " + Trim(ComboBox1.Text))
End If
End Sub
Sub normal()
Button1.Text = "Tambah"
Button1.Enabled = True
Button2.Text = "Ubah"
Button2.Enabled = True
Button3.Text = "Hapus"
Button3.Enabled = True
Button4.Text = "Keluar"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "Keluar" Then
Me.Close()
Else
Call isibersih()
Call normal()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "Ubah" Then
Button1.Enabled = False
Button2.Text = "simpan"
Button3.Enabled = False
Button4.Text = "Batal"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text = "Hapus" Then
Button1.Enabled = False
Button2.Enabled = False
Button3.Text = "OK"
Button4.Text = "Batal"
End If
End Sub
End Class
Setelah selesai sintaksnya lalu kita running atau tekan F5
0 komentar:
Posting Komentar