Tugas Pemrograman Visual 3
Modifikasi dari Tugas 2 :
1). Saat
program dijalakan, semua isian tidak aktif, tombol isi data dan tutup aktif
sedangkan tombol clear tidak aktif.
berikut adalah method nya :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As Windows.Forms.Control
For Each a In Me.Controls
If a.GetType.Name = "TextBox" Then
a.Enabled = False
ElseIf a.GetType.Name = "ComboBox" Then
a.Enabled = False
ElseIf a.GetType.Name = "RadioButton" Then
a.Enabled = False
End If
btclear.Enabled = False
Next
cmbkode.Items.Add("SPT")
cmbkode.Items.Add("SND")
cmbkode.Items.Add("TST")
cmbkode.Items.Add("TOP")
cmbkode.Items.Add("TAS")
End Sub
Dim a As Windows.Forms.Control
For Each a In Me.Controls
If a.GetType.Name = "TextBox" Then
a.Enabled = False
ElseIf a.GetType.Name = "ComboBox" Then
a.Enabled = False
ElseIf a.GetType.Name = "RadioButton" Then
a.Enabled = False
End If
btclear.Enabled = False
Next
cmbkode.Items.Add("SPT")
cmbkode.Items.Add("SND")
cmbkode.Items.Add("TST")
cmbkode.Items.Add("TOP")
cmbkode.Items.Add("TAS")
End Sub
Printscreen 1 |
2). Saat tombol isi data ditekan, kodebarang, jumlah barang, cara beli dan tombol clear aktif, sedangkan tombol isidata tidak aktif.
berikut adalah method nya :
Private Sub btisidata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btisidata.Click
Dim b As Windows.Forms.Control
For Each b In Me.Controls
If b.GetType.Name = "ComboBox" Then
b.Enabled = True
ElseIf b.GetType.Name = "RadioButton" Then
b.Enabled = True
End If
btclear.Enabled = True
bttutup.Enabled = False
txtjumlah.Enabled = True
btisidata.Enabled = False
Next
End Sub
Printscreen 2 |
3). Lalu saat tombol clear di jalankan ....
berikut adalah method nya :
Private Sub btclear_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclear.Click
Dim c As Windows.Forms.Control
For Each c In Me.Controls
If c.GetType.Name = "TextBox" Then
c.Enabled = False
ElseIf c.GetType.Name = "ComboBox" Then
c.Enabled = False
ElseIf c.GetType.Name = "RadioButton" Then
c.Enabled = False
End If
btclear.Enabled = False
btisidata.Enabled = True
bttutup.Enabled = True
Next
txtbayar.Clear()
txtdiskon.Clear()
txtharga.Clear()
txtjumlah.Clear()
txtnama.Clear()
txttotal.Clear()
Me.radiotunai.Checked = False
Me.radiokredit.Checked = False
cmbkode.Text = ""
End Sub
Printscreen 3 |
Berikut adalah tugas ke-2 nya :
Membuat Puzzle
Berikut method koding nya :
Public Class Form1
Public tampung As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim control As Windows.Forms.Control
For Each control In Me.Controls
If control.GetType.Name = "Button" Then
bt1.Text = "6"
bt2.Text = "1"
bt3.Text = "8"
bt4.Text = "7"
bt5.Text = "5"
bt6.Text = "2"
bt7.Text = "4"
bt8.Text = "3"
bt9.Text = " "
End If
Next
End Sub
Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1.Click
If bt2.Text = " " Then
tampung = bt1.Text
bt1.Text = bt2.Text
bt2.Text = tampung
ElseIf bt4.Text = " " Then
tampung = bt1.Text
bt1.Text = bt4.Text
bt4.Text = tampung
End If
berhasil()
End Sub
Private Sub bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt2.Click
If bt1.Text = " " Then
tampung = bt2.Text
bt2.Text = bt1.Text
bt1.Text = tampung
ElseIf bt3.Text = " " Then
tampung = bt2.Text
bt2.Text = bt3.Text
bt3.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt2.Text
bt2.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt3.Click
If bt2.Text = " " Then
tampung = bt3.Text
bt3.Text = bt2.Text
bt2.Text = tampung
ElseIf bt6.Text = " " Then
tampung = bt3.Text
bt3.Text = bt6.Text
bt6.Text = tampung
End If
berhasil()
End Sub
Private Sub bt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt4.Click
If bt1.Text = " " Then
tampung = bt4.Text
bt4.Text = bt1.Text
bt1.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt4.Text
bt4.Text = bt5.Text
bt5.Text = tampung
ElseIf bt7.Text = " " Then
tampung = bt4.Text
bt4.Text = bt7.Text
bt7.Text = tampung
End If
berhasil()
End Sub
Private Sub bt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt5.Click
If bt2.Text = " " Then
tampung = bt5.Text
bt5.Text = bt2.Text
bt2.Text = tampung
ElseIf bt4.Text = " " Then
tampung = bt5.Text
bt5.Text = bt4.Text
bt4.Text = tampung
ElseIf bt6.Text = " " Then
tampung = bt5.Text
bt5.Text = bt6.Text
bt6.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt5.Text
bt5.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub bt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt6.Click
If bt9.Text = " " Then
tampung = bt6.Text
bt6.Text = bt9.Text
bt9.Text = tampung
ElseIf bt3.Text = " " Then
tampung = bt6.Text
bt6.Text = bt3.Text
bt3.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt6.Text
bt6.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt7.Click
If bt4.Text = " " Then
tampung = bt7.Text
bt7.Text = bt4.Text
bt4.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt7.Text
bt7.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub bt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt8.Click
If bt9.Text = " " Then
tampung = bt8.Text
bt8.Text = bt9.Text
bt9.Text = tampung
ElseIf bt7.Text = " " Then
tampung = bt8.Text
bt8.Text = bt7.Text
bt7.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt8.Text
bt8.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt9.Click
If bt6.Text = " " Then
tampung = bt9.Text
bt9.Text = bt6.Text
bt6.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt9.Text
bt9.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub berhasil()
If bt1.Text = "1" And bt2.Text = "2" And bt3.Text = "3" And bt4.Text = "4" And bt5.Text = "5" And bt6.Text = "6" And bt7.Text = "7" And bt8.Text = "8" Then
MessageBox.Show("SELAMAT ANDA BERHASIL")
End If
End Sub
Private Sub btacak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btacak.Click
Dim jalan As Integer
If btacak.Text = "&ACAK" Then
btacak.Text = "&STOP"
ElseIf btacak.Text = "&STOP" Then
btacak.Text = "&ACAK"
End If
Timer1.Enabled = jalan
jalan = Not jalan
Dim a As Windows.Forms.Control
For Each a In Me.Controls
If a.Tag = "1" Then
a.Enabled = True
End If
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim jalan As Integer
jalan = Rnd() * 10
bt1.Text = jalan
Timer1.Enabled = False
End Sub
Private Sub btkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btkeluar.Click
If MsgBox("Apakah Anda ingin keluar ? ", 4 + 32 + 256, _
"Keluar") = vbYes Then
Me.Close()
End If
End Sub
End Class
Public tampung As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim control As Windows.Forms.Control
For Each control In Me.Controls
If control.GetType.Name = "Button" Then
bt1.Text = "6"
bt2.Text = "1"
bt3.Text = "8"
bt4.Text = "7"
bt5.Text = "5"
bt6.Text = "2"
bt7.Text = "4"
bt8.Text = "3"
bt9.Text = " "
End If
Next
End Sub
Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1.Click
If bt2.Text = " " Then
tampung = bt1.Text
bt1.Text = bt2.Text
bt2.Text = tampung
ElseIf bt4.Text = " " Then
tampung = bt1.Text
bt1.Text = bt4.Text
bt4.Text = tampung
End If
berhasil()
End Sub
Private Sub bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt2.Click
If bt1.Text = " " Then
tampung = bt2.Text
bt2.Text = bt1.Text
bt1.Text = tampung
ElseIf bt3.Text = " " Then
tampung = bt2.Text
bt2.Text = bt3.Text
bt3.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt2.Text
bt2.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt3.Click
If bt2.Text = " " Then
tampung = bt3.Text
bt3.Text = bt2.Text
bt2.Text = tampung
ElseIf bt6.Text = " " Then
tampung = bt3.Text
bt3.Text = bt6.Text
bt6.Text = tampung
End If
berhasil()
End Sub
Private Sub bt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt4.Click
If bt1.Text = " " Then
tampung = bt4.Text
bt4.Text = bt1.Text
bt1.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt4.Text
bt4.Text = bt5.Text
bt5.Text = tampung
ElseIf bt7.Text = " " Then
tampung = bt4.Text
bt4.Text = bt7.Text
bt7.Text = tampung
End If
berhasil()
End Sub
Private Sub bt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt5.Click
If bt2.Text = " " Then
tampung = bt5.Text
bt5.Text = bt2.Text
bt2.Text = tampung
ElseIf bt4.Text = " " Then
tampung = bt5.Text
bt5.Text = bt4.Text
bt4.Text = tampung
ElseIf bt6.Text = " " Then
tampung = bt5.Text
bt5.Text = bt6.Text
bt6.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt5.Text
bt5.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub bt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt6.Click
If bt9.Text = " " Then
tampung = bt6.Text
bt6.Text = bt9.Text
bt9.Text = tampung
ElseIf bt3.Text = " " Then
tampung = bt6.Text
bt6.Text = bt3.Text
bt3.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt6.Text
bt6.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt7.Click
If bt4.Text = " " Then
tampung = bt7.Text
bt7.Text = bt4.Text
bt4.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt7.Text
bt7.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub bt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt8.Click
If bt9.Text = " " Then
tampung = bt8.Text
bt8.Text = bt9.Text
bt9.Text = tampung
ElseIf bt7.Text = " " Then
tampung = bt8.Text
bt8.Text = bt7.Text
bt7.Text = tampung
ElseIf bt5.Text = " " Then
tampung = bt8.Text
bt8.Text = bt5.Text
bt5.Text = tampung
End If
berhasil()
End Sub
Private Sub bt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt9.Click
If bt6.Text = " " Then
tampung = bt9.Text
bt9.Text = bt6.Text
bt6.Text = tampung
ElseIf bt8.Text = " " Then
tampung = bt9.Text
bt9.Text = bt8.Text
bt8.Text = tampung
End If
berhasil()
End Sub
Private Sub berhasil()
If bt1.Text = "1" And bt2.Text = "2" And bt3.Text = "3" And bt4.Text = "4" And bt5.Text = "5" And bt6.Text = "6" And bt7.Text = "7" And bt8.Text = "8" Then
MessageBox.Show("SELAMAT ANDA BERHASIL")
End If
End Sub
Private Sub btacak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btacak.Click
Dim jalan As Integer
If btacak.Text = "&ACAK" Then
btacak.Text = "&STOP"
ElseIf btacak.Text = "&STOP" Then
btacak.Text = "&ACAK"
End If
Timer1.Enabled = jalan
jalan = Not jalan
Dim a As Windows.Forms.Control
For Each a In Me.Controls
If a.Tag = "1" Then
a.Enabled = True
End If
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim jalan As Integer
jalan = Rnd() * 10
bt1.Text = jalan
Timer1.Enabled = False
End Sub
Private Sub btkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btkeluar.Click
If MsgBox("Apakah Anda ingin keluar ? ", 4 + 32 + 256, _
"Keluar") = vbYes Then
Me.Close()
End If
End Sub
End Class
Printscreen Puzzle |
Saya mohon maaf atas keterlambatannya, karena banyak halangan saat akan mengerjakan tugas ini.
saya sadar akan hal tersebut, saya harap ketersediaannya.
atas segala kekurangannya saya mohon maaf.
Terimakasih atas perhatiannya Bapak Nandang Hermanto.
:-)
by Anton Nugroho