aplikasi "Lucky 6" dadu ini akan menampikan sebuah gambar apabila semua dadu bermata 6. Bagaimanakah cara membuat aplikasi sederhana tersebut?. Berikut codenya :
Public Class Form1
Dim m, m2, m3 As Integer
Dim p As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox4.Visible = False
m = CStr(Int(Rnd() * 6) + 1)
m2 = CStr(Int(Rnd() * 6) + 1)
m3 = CStr(Int(Rnd() * 6) + 1)
Select Case m
Case 1
PictureBox1.Image = ImageList1.Images.Item(0)
Case 2
PictureBox1.Image = ImageList1.Images.Item(1)
Case 3
PictureBox1.Image = ImageList1.Images.Item(2)
Case 4
PictureBox1.Image = ImageList1.Images.Item(3)
Case 5
PictureBox1.Image = ImageList1.Images.Item(4)
Case 6
PictureBox1.Image = ImageList1.Images.Item(5)
End Select
Select Case m2
Case 1
PictureBox2.Image = ImageList1.Images.Item(0)
Case 2
PictureBox2.Image = ImageList1.Images.Item(1)
Case 3
PictureBox2.Image = ImageList1.Images.Item(2)
Case 4
PictureBox2.Image = ImageList1.Images.Item(3)
Case 5
PictureBox2.Image = ImageList1.Images.Item(4)
Case 6
PictureBox2.Image = ImageList1.Images.Item(5)
End Select
Select Case m3
Case 1
PictureBox3.Image = ImageList1.Images.Item(0)
Case 2
PictureBox3.Image = ImageList1.Images.Item(1)
Case 3
PictureBox3.Image = ImageList1.Images.Item(2)
Case 4
PictureBox3.Image = ImageList1.Images.Item(3)
Case 5
PictureBox3.Image = ImageList1.Images.Item(4)
Case 6
PictureBox3.Image = ImageList1.Images.Item(5)
End Select
If (m = "6" And m2 = "6") Or (m = "6" And m3 = "6") Or (m2 = "6" And m3 = "6") Then
PictureBox4.Visible = True
Beep()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox4.Visible = False
m = CStr(Int(Rnd() * 6) + 1)
m2 = CStr(Int(Rnd() * 6) + 1)
m3 = CStr(Int(Rnd() * 6) + 1)
Select Case m
Case 1
PictureBox1.Image = ImageList1.Images.Item(0)
Case 2
PictureBox1.Image = ImageList1.Images.Item(1)
Case 3
PictureBox1.Image = ImageList1.Images.Item(2)
Case 4
PictureBox1.Image = ImageList1.Images.Item(3)
Case 5
PictureBox1.Image = ImageList1.Images.Item(4)
Case 6
PictureBox1.Image = ImageList1.Images.Item(5)
End Select
Select Case m2
Case 1
PictureBox2.Image = ImageList1.Images.Item(0)
Case 2
PictureBox2.Image = ImageList1.Images.Item(1)
Case 3
PictureBox2.Image = ImageList1.Images.Item(2)
Case 4
PictureBox2.Image = ImageList1.Images.Item(3)
Case 5
PictureBox2.Image = ImageList1.Images.Item(4)
Case 6
PictureBox2.Image = ImageList1.Images.Item(5)
End Select
Select Case m3
Case 1
PictureBox3.Image = ImageList1.Images.Item(0)
Case 2
PictureBox3.Image = ImageList1.Images.Item(1)
Case 3
PictureBox3.Image = ImageList1.Images.Item(2)
Case 4
PictureBox3.Image = ImageList1.Images.Item(3)
Case 5
PictureBox3.Image = ImageList1.Images.Item(4)
Case 6
PictureBox3.Image = ImageList1.Images.Item(5)
If (m = "6" And m2 = "6") Or (m = "6" And m3 = "6") Or (m2 = "6" And m3 = "6") Then
PictureBox4.Visible = True
Beep()
End If
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
p = Button2.Text
Select Case p
Case "Start"
Timer1.Enabled = True
Button2.Text = "Stop"
Case "Stop"
Timer1.Enabled = False
Button2.Text = "Start"
End Select
End Sub
End Class
untuk file selengkapnya bisa di unduh disini. unduh
Thanks bro ...
BalasHapusini berguna!
Untuk buat Game Mono Poli sederhana :3
mampir juga untuk tutorialnya di https://www.youtube.com/channel/UCLl48YOgQswobrSL7OryAJQ
BalasHapus