Soal
1
Pada soal yang perama kita hanya memodifikasi dari
pertemuan yang sebelumnya. Hal yang saya
lakukan dalam memodifikasi program ini adalah sebagai beerikut:
- Tambahkan
satu button dan atur properties sesuai yang kita inginkan, misalkan:
object
|
properties
|
value
|
Button
|
Name
text
|
Btisidata
Isi data
|
Isikan program sebagai berikut:
Private Sub Btisidata_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btisidata.Click
Dim
type3 As Windows.Forms.Control
For Each type3 In Me.Controls
If
type3.GetType.Name = "ComboBox" Or type3.GetType.Name = "TextBox"
Or type3.GetType.Name = "RadioButton" Or
type3.Name = "btnbersihkan" Then
type3.Visible = True
ElseIf
type3.Name = "Btisidata" Then
type3.Visible = False
End
If
Next
End Sub
End Class
- Isikan program berikut pada button bersihkan
Private Sub
btnbersihkan_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnbersihkan.Click
txtdiskon.Clear()
txtharga.Clear()
txtjumlah.Clear()
Txtnama.Clear()
txttotalbayar.Clear()
txttotalharga.Clear()
Cmbkode.Text = ""
Me.rdkredit.Checked = False
Me.rdtunai.Checked
= False
If txttotalharga.Text = ""
Then
txtdiskon.Text = ""
txttotalbayar.Text = ""
End If
Dim type2 As
Windows.Forms.Control
For Each type2 In Me.Controls
If type2.GetType.Name = "TextBox"
Or type2.GetType.Name = "ComboBox" Or
type2.GetType.Name = "RadioButton"
Or type2.Name = "btnbersihkan"
Then
type2.Visible = False
ElseIf type2.Name = "Btisidata"
Then
type2.Visible = True
End If
Next
End Sub
- Isikan
program berikut pada form
Public Class
Frmlatdua
Private Sub
Frmlatdua_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
Cmbkode.Items.Add("SND")
Cmbkode.Items.Add("TAS")
Cmbkode.Items.Add("TOP")
Cmbkode.Items.Add("SPT")
Dim type1 As
Windows.Forms.Control
For Each type1 In Me.Controls
If type1.GetType.Name = "TextBox"
Or type1.GetType.Name = "ComboBox" Or
type1.GetType.Name = "RadioButton"
Or type1.Name = "btnbersihkan"
Then
type1.Visible = False
End If
Next
End Sub
Hanya itu yang saya
lakukan dalam memodifikasi program ini. Pada saat program dijalankan hasilnya
sebagai berikut:
Kemudian kita click
tombol isi data.
Kemudian kita isikan
sesuai dengan yang kita inginkan, misal:
Kita click tombol
bersihkan
Soal
2
Membuat permainan
puzzle sederhana. Langsung kodeprogramnya saja.
- Isikan program berikut pada bt1
Private Sub bt1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt1.Click
If
bt2.Text = "" Then
bt2.Text = bt1.Text
bt1.Text = ""
ElseIf
bt4.Text = "" Then
bt4.Text = bt1.Text
bt1.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
-
Isikan program berikut pada bt2
Private Sub bt2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt2.Click
If
bt1.Text = "" Then
bt1.Text = bt2.Text
bt2.Text = ""
ElseIf
bt3.Text = "" Then
bt3.Text = bt2.Text
bt2.Text = ""
ElseIf
bt5.Text = "" Then
bt5.Text = bt2.Text
bt2.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
-
Isikan program berikut pada bt3
Private Sub bt3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt3.Click
If
bt2.Text = "" Then
bt2.Text = bt3.Text
bt3.Text = ""
ElseIf
bt6.Text = "" Then
bt6.Text = bt3.Text
bt3.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End
If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
-
Isikan program berikut pada bt4
Private Sub bt4_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt4.Click
If
bt1.Text = "" Then
bt1.Text = bt4.Text
bt4.Text = ""
ElseIf
bt7.Text = "" Then
bt7.Text = bt4.Text
bt4.Text = ""
ElseIf
bt5.Text = "" Then
bt5.Text = bt4.Text
bt4.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
·
Isikan program berikut pada bt5
Private Sub bt5_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt5.Click
If
bt2.Text = "" Then
bt2.Text = bt5.Text
bt5.Text = ""
ElseIf
bt8.Text = "" Then
bt8.Text = bt5.Text
bt5.Text = ""
ElseIf
bt4.Text = "" Then
bt4.Text = bt5.Text
bt5.Text = ""
ElseIf
bt6.Text = "" Then
bt6.Text = bt5.Text
bt5.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
·
Isikan program berikut pada bt6
Private Sub bt6_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt6.Click
If
bt9.Text = "" Then
bt9.Text = bt6.Text
bt6.Text = ""
ElseIf
bt5.Text = "" Then
bt5.Text = bt6.Text
bt6.Text = ""
ElseIf
bt3.Text = "" Then
bt3.Text = bt6.Text
bt6.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End
If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
·
Isikan program berikut pada bt7
Private Sub bt7_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt7.Click
If
bt8.Text = "" Then
bt8.Text = bt7.Text
bt7.Text = ""
ElseIf
bt4.Text = "" Then
bt4.Text = bt7.Text
bt7.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
·
Isikan program berikut pada bt8
Private Sub bt8_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt8.Click
If
bt9.Text = "" Then
bt9.Text = bt8.Text
bt8.Text = ""
ElseIf
bt7.Text = "" Then
bt7.Text = bt8.Text
bt8.Text = ""
ElseIf
bt5.Text = "" Then
bt5.Text = bt8.Text
bt8.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End If
End If
End If
End If
End If
End
If
End
If
End If
End If
End Sub
·
Isikan program berikut pada bt9
Private Sub bt9_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles bt9.Click
If
bt6.Text = "" Then
bt6.Text = bt9.Text
bt9.Text = ""
ElseIf
bt8.Text = "" Then
bt8.Text = bt9.Text
bt9.Text = ""
End If
If
bt1.Text = "1" Then
If
bt2.Text = "2" Then
If
bt3.Text = "3" Then
If
bt4.Text = "4" Then
If bt5.Text = "5" Then
If bt6.Text = "6"
Then
If bt7.Text = "7"
Then
If bt8.Text = "8"
Then
If bt9.Text = ""
Then
MessageBox.Show("Selamat Anda
Berhasil", "Selamatyah..",
MessageBoxButtons.OK)
Else
End
If
End If
End If
End If
End If
End
If
End
If
End
If
End If
End Sub
End Class
Hasil yang akan
ditampilkan pada saat kita menjalankan program tersebut adalah sebagai
berikut:
Setelah kita berhasil
mengurutkan angka-angkanya dari 1 sampai 8, akan muncul pesan sebagai berikut.