Ga' usah terlalu banyak basa basi langsung saja kita ke TKP...
buat project baru pada progam VB pastinya kemudian beri nama project tersebut sesuai selera masing2, kemudian pada form kita buat seperti gambar berikut ini :
Setelah kita buat formnya kemudian kita kasih sintaknya (source codenya) berikut ini :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
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 Akutansi")
End Sub
Sub isibersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
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 = "Simpan"
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"
Button2.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.Text = 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
Selanjutnya kita jalankan program tersebut dan hasilnya akan seperti berikut :
Note : untuk pengisian datanya terserah kita.
Terima kasih semoga bermanfaat,
Kebenaran pasti datangnya dari Allah SWT, dan kesalahan datangnya dari saya.
0 komentar:
Posting Komentar