Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim a(100) As Integer '第23-3題回放才用的到
- Dim Place(8) As Integer
- '第一題,計算炸彈數,邊界問題可以忽略
- '炸彈的tag已經標示成1,共有10顆
- Private Sub Command1_Click(index As Integer)
- If Command1(index).Tag = "1" Then
- Command1(index).Picture = Image1.Picture
- MsgBox "boom!!!"
- Else
- If Command1(index).Caption = "" Then
- Label1 = Label1 + 1
- If Label1.Caption = 90 Then
- MsgBox "you win"
- End If
- End If
- a(Label1) = index
- BFS (index)
- End If
- End Sub
- '第二題,地雷紅旗標示
- 'button會傳回滑鼠狀態,1表示左鍵,2表右鍵,4表中鍵
- 'image2是旗子,image3是空白圖
- '按第一下插旗,按第二下收回旗子
- Private Sub Command1_MouseDown(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
- '第三題,已經翻開不要插旗
- If Command1(index).Caption = "" Then
- If Button = 2 Then
- If Command1(index).Picture = Image3.Picture Then
- Command1(index).Picture = Image2.Picture
- Else
- Command1(index).Picture = Image3.Picture
- End If
- End If
- Else
- Command1(index).Picture = Image3.Picture
- End If
- End Sub
- '第四題,解邊界問題
- '以下勿動,埋入10個地雷方便你第一題測試
- Private Sub Command2_Click()
- Label1.Caption = 0
- For i = 0 To 143
- Command1(i).Tag = ""
- Command1(i).Caption = ""
- Command1(i).Picture = Image3.Picture
- Next
- Randomize
- n = 0
- Do
- X = Int(Rnd * 144)
- If Command1(X).Tag = "" And Command1(X).Visible = True Then
- n = n + 1
- Command1(X).Tag = "1"
- 'Command1(X).Caption = n
- End If
- Loop Until n = 10
- End Sub
- Private Sub Command3_Click()
- Timer1.Interval = 500
- Label3 = 0
- Label2 = Label1
- If Int(Label3) > Int(Label2) Then
- Timer1.Interval = 0
- End If
- End Sub
- Private Sub Timer1_Timer()
- If Int(Label3) <= Int(Label2) Then
- Command1_Click (a(Label3))
- Label3 = Label3 + 1
- End If
- End Sub
- '第4題,1.完成BFS的最後一個if
- '2.你要修改Command1_Click裡面某段,而且會用到BFS ?????
- Private Sub BFS(index As Integer)
- If Command1(index).Visible = True And Command1(index).Caption = "" Then
- If Command1(index).Caption = "" Then
- Label1.Caption = Label1.Caption + 1
- If Label1.Caption = 90 Then
- MsgBox "you win"
- End If
- End If
- a(Label1) = index
- Command1(index).Caption = 0
- Command1(index).Picture = Image3.Picture
- If Command1(index - 13).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index - 12).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index - 11).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index - 1).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index + 1).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index + 11).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index + 12).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- If Command1(index + 13).Tag = "1" Then
- Command1(index).Caption = Command1(index).Caption + 1
- End If
- '*********4-1開始
- If Command1(index).Caption = 0 Then
- BFS index - 13
- BFS index - 12
- BFS index - 11
- BFS index - 1
- BFS index + 1
- BFS index + 11
- BFS index + 12
- BFS index + 13
- '*********4-1結束,接著你要修改Command1_Click裡面某段,而且會用到BFS ?????
- End If
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement