## latihan VB.net desain form database berserta scrib ringan ##
@ langkah pertama dalam pelatihan ini silahkan anda membuat desain seperti pada gambar berikut :
@ langkah yang kedua adalah silahkan anda membuat scrib seperti berikut !!!
Public Class Form1
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call isiCombo()
Call bersih()
End Sub
Sub isiCombo()
ComboBox1.Items.Add("06 tehnik informatika")
ComboBox1.Items.Add("07 sistem informasi")
ComboBox1.Items.Add("26 manajemen informasi")
ComboBox1.Items.Add("67 komputer akuntansi")
ComboBox1.Items.Add("05 tehnik komputer")
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
ComboBox1.Text = "06 tehnik informatika"
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(ComboBox1.Text) + "" + Trim(TextBox1.Text) + "" + Trim(TextBox2.Text) + Trim(TextBox3.Text) + "" + Trim(TextBox4.Text)
End If
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()
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call isiCombo()
Call bersih()
End Sub
Sub isiCombo()
ComboBox1.Items.Add("06 tehnik informatika")
ComboBox1.Items.Add("07 sistem informasi")
ComboBox1.Items.Add("26 manajemen informasi")
ComboBox1.Items.Add("67 komputer akuntansi")
ComboBox1.Items.Add("05 tehnik komputer")
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
ComboBox1.Text = "06 tehnik informatika"
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(ComboBox1.Text) + "" + Trim(TextBox1.Text) + "" + Trim(TextBox2.Text) + Trim(TextBox3.Text) + "" + Trim(TextBox4.Text)
End If
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 bersih()
Call normal()
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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "ubah" Then
Button1.Enabled = False
Button3.Enabled = False
Button4.Enabled = True
TextBox1.Text = Focus()
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
Button4.Enabled = True
TextBox1.Text = Focus()
End If
End Sub
End Class
Call bersih()
Call normal()
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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "ubah" Then
Button1.Enabled = False
Button3.Enabled = False
Button4.Enabled = True
TextBox1.Text = Focus()
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
Button4.Enabled = True
TextBox1.Text = Focus()
End If
End Sub
End Class
***catatan bos (penting )
1.perintah call adalah untuk menjalankan program dalam sub
contoh : call bersih() untuk menjalankan scrib yang ada dalam program sub bersih()
2.perhatikan dalam pembuatan scrib yang pertama dalam call isicombo() dan call bersih() tipe desain adalah form1 Events dengan declaration Activated >>>>>>> penting!!!!
3.fungsi Me.Close() adalah untuk menjalankan diri sendiri.
@ maka hasilnya adalah sebagai berikut :
** maaf untuk hasil ini hanya 1 button saja yang dijalankan untuk lebih jelasnya silahkan coba yah itung-itung sebagai latihan lah gan biar terbiasa ok demikian pelatihan dari saya semoga bermanfaat selamat mencoba cuy !!!
0 komentar:
Posting Komentar