Public Class Form1
Dim bomb As Integer
Dim bomb1 As Integer
Dim bomb2 As Integer
Dim count As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Randomize()
bomb = Int(Rnd() * 6) + 1
For i = 1 To 10
bomb1 = Int(Rnd() * 6) + 1
If bomb1 <> bomb Then Exit For
Next
For j = 1 To 10
bomb2 = Int(Rnd() * 6) + 1
If bomb2 <> bomb And bomb2 <> bomb1 Then Exit For
Next
End Sub
Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
Call checkBomb(1)
If Label1.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Private Sub Label2_Click(sender As System.Object, e As System.EventArgs) Handles Label2.Click
Call checkBomb(2)
If Label2.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Private Sub Label3_Click(sender As System.Object, e As System.EventArgs) Handles Label3.Click
Call checkBomb(3)
If Label3.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Private Sub Label4_Click(sender As System.Object, e As System.EventArgs) Handles Label4.Click
Call checkBomb(4)
If Label4.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Private Sub Label5_Click(sender As System.Object, e As System.EventArgs) Handles Label5.Click
Call checkBomb(5)
If Label5.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Private Sub Label6_Click(sender As System.Object, e As System.EventArgs) Handles Label6.Click
Call checkBomb(6)
If Label6.Text = "N" Then
MsgBox("爆炸了!") : count = count + 1
Label8.Text = count
If Label8.Text = 3 Then MsgBox("連爆三次,遊戲結束!")
End If
End Sub
Sub checkBomb(ByVal x)
If bomb = x Or bomb1 = x Or bomb2 = x Then
Select Case x
Case 1 : Label1.Text = "N"
Case 2 : Label2.Text = "N"
Case 3 : Label3.Text = "N"
Case 4 : Label4.Text = "N"
Case 5 : Label5.Text = "N"
Case 6 : Label6.Text = "N"
End Select
End If
End Sub
End Class
沒有留言:
張貼留言