Analisis Listing Program Puzzle Angka
Form 1
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Form2.Show()
Me.Hide()
Dim a(8), i, j, RN As
Integer
Dim jalan As Boolean
jalan
= False
i = 1
a(j)
= 1
Do While i <= 8
Randomize()
RN = CInt(Int((8 * Rnd()) + 1))
For j = 1 To i
If (a(j) = RN) Then
jalan = True
Exit
For
End If
Next
If jalan = True Then
jalan = False
Else
a(i) = RN
i = i + 1
End If
Loop
Form2.Button1.Text = a(1)
Form2.Button2.Text = a(2)
Form2.Button3.Text = a(3)
Form2.Button4.Text = a(4)
Form2.Button5.Text = a(5)
Form2.Button6.Text = a(6)
Form2.Button7.Text = a(7)
Form2.Button8.Text = a(8)
Form2.Button9.Text = ""
End Sub
Ø
Menunjukan bahwa apabila kita mengklik tombol
start, maka puzzle angka pada form selanjutnya akan randomize dan melanjutkan
ke form selanjutnya
Form2
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
CheckButton(Button1, Button2)
CheckButton(Button1, Button4)
CheckSolved()
End Sub
Ø
Listing ini menunjukan jika puzzle angka diklik
maka akan pindah ke button lainnya (berlaku untuk button lainnya)
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
Dim x = MsgBox("Are
you sure want to exit?", vbYesNo + vbQuestion)
If (x = Windows.Forms.DialogResult.No)
Then
Me.Show()
Else
Me.Close()
Solve_the_Puzzle.Close()
End If
End Sub
Ø
Menunjukan apabila kita mengklik tombol exit,
maka akan muncul messagebox (yes dan no)
Private Sub
Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button11.Click
Dim a(8), i, j, RN As
Integer
Dim jalan As Boolean
jalan
= False
i = 1
a(j)
= 1
Do While i <= 8
Randomize()
RN = CInt(Int((8 * Rnd()) + 1))
For j = 1 To i
If (a(j) = RN) Then
jalan = True
Exit For
End If
Next
If jalan = True Then
jalan = False
Else
a(i) = RN
i = i + 1
End If
Loop
Button1.Text = a(1)
Button2.Text = a(2)
Button3.Text = a(3)
Button4.Text = a(4)
Button5.Text = a(5)
Button6.Text = a(6)
Button7.Text = a(7)
Button8.Text = a(8)
Button9.Text = ""
End Sub
Ø
Maksudnya agar kita dapat mengacak kembali
puzzlenya
Form3
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
TextBox1.Clear()
End Sub
Ø Menunjukan apabila kita mengklik
tombol clear maka textbox akan clear dari tulisan
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button1.Click
Form4.Show()
Me.Hide()
End Sub
Ø Menunjukan jika kita mengklik ok
maka akan muncul form selanjutnya
Form4
Private Sub Form4_Load(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles MyBase.Load
Label2.Text = Form3.TextBox1.Text
End Sub
Ø Menunjukan bahwa teks pada label2
sama dengan teks pada textbox1 di form sebelumnya
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Form2.Show()
Me.Close()
Form2.Show()
Me.Hide()
End Sub
Ø Menjelaskan bahwa apabila kita
mengklik tombol replay, maka akan kembali ke form puzzle
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Dim x = MsgBox("Are
you sure want to exit?", vbYesNo + vbQuestion)
If (x = Windows.Forms.DialogResult.No)
Then
Me.Show()
Else
Me.Close()
Solve_the_Puzzle.Close()
End If
End Sub
Ø Menunjukan apabila kita mengklik
tombol exit, maka akan muncul messagebox(yes dan no)
FLOWCHART
untuk mendownload program, klik disini
Tidak ada komentar:
Posting Komentar