收藏的扫雷

Public num As Integer, i As Integer, j As Integer, k As Integer, num2 As Integer, num3 As Integer
Dim num4 As Integer
Dim all As Boolean
'num2 为雷的个数,NUM为全局变量,num3的数值为周围雷的个数!'num4为内部的判断是否相符,初始为5
'在begingame中将NUM2出使化为5
'Download by http://down.liehuo.net
Private Sub check3() '这是我后来加的,在输了这后,显示正确的答案!
For i = 0 To L1.Count - 1 '用c1.count和24都一样
   If L1(i).Caption = "●" Then
      C1(i).Visible = False
      
       ElseIf C1(i).Caption = "雷" Then
            C1(i).Visible = False
            L1(i).ForeColor = &HC000&
            L1(i).FontBold = 1
            L1(i).FontSize = 20
            L1(i).Caption = "×"
          End If
          C1(i).Enabled = False '让按钮不可用!
      Next i
      


End Sub

Private Sub check2()
'这里我做的不是很好,数组的转化不好做,还好,不是很多.我是用了枚举法 求出 L1上显示雷的个数!
'用上返回值!num
L1(num).ForeColor = &HC00000
L1(num).FontBold = True
L1(num).FontSize = 25
Select Case num '这里面一定要换行,否则会出错!!!
    Case 0
    num3 = 0
        If L1(1).Caption = "●" Then '这里不要嵌套!!!!
          num3 = num3 + 1
        End If
        If L1(5).Caption = "●" Then
            num3 = num3 + 1
        End If
        If L1(6).Caption = "●" Then
             num3 = num3 + 1
        End If
        If num3 <> 0 Then
            L1(num).Caption = num3
        End If
  '********************************************************************
    Case 1
    num3 = 0
        If L1(0).Caption = "●" Then
             num3 = num3 + 1
             End If
            If L1(2).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(5).Caption = "●" Then
            num3 = num3 + 1
            End If
              If L1(6).Caption = "●" Then
            num3 = num3 + 1
            End If
               If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
   If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '********************************************************************
  Case 2
  num3 = 0
     If L1(1).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(3).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(6).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
      If num3 <> 0 Then
        L1(num).Caption = num3
        End If
     '*****************************************************************
   Case 3
   num3 = 0
        If L1(2).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(4).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(9).Caption = "●" Then
            num3 = num3 + 1
            End If
    If num3 <> 0 Then
        L1(num).Caption = num3
        End If
   '********************************************************************
   Case 4
   num3 = 0
        If L1(3).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(9).Caption = "●" Then
            num3 = num3 + 1
            End If
    If num3 <> 0 Then
        L1(num).Caption = num3
        End If
   '*******************************************************************
   Case 5
   num3 = 0
        If L1(0).Caption = "●" Then
                  num3 = num3 + 1
                  End If
         If L1(1).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(6).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(10).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(11).Caption = "●" Then
        num3 = num3 + 1
        End If
   If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '*********************************************************************
    Case 6
   num3 = 0
            If L1(0).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(1).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(2).Caption = "●" Then
            num3 = num3 + 1
            End If
              If L1(5).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(10).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(11).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
      If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '*******************************************************************
   Case 7
   num3 = 0
            If L1(1).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(2).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(3).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(6).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(11).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(13).Caption = "●" Then
            num3 = num3 + 1
            End If
       If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '**********************************************************************
    Case 8
   num3 = 0
            If L1(2).Caption = "●" Then
                        num3 = num3 + 1
                        End If
            If L1(3).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(4).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(9).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(13).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(14).Caption = "●" Then
            num3 = num3 + 1
            End If
     If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '**********************************************************************
   Case 9
   num3 = 0
        If L1(3).Caption = "●" Then
                  num3 = num3 + 1
                  End If
         If L1(4).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(8).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(13).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(14).Caption = "●" Then
        num3 = num3 + 1
        End If
      If num3 <> 0 Then
        L1(num).Caption = num3
        End If
   '****************************************************************
   Case 10
   num3 = 0
        If L1(5).Caption = "●" Then
                  num3 = num3 + 1
                  End If
         If L1(6).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(11).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(15).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(16).Caption = "●" Then
        num3 = num3 + 1
        End If
      If num3 <> 0 Then
        L1(num).Caption = num3
        End If
   '****************************************************************
   Case 11
   num3 = 0
            If L1(5).Caption = "●" Then
                        num3 = num3 + 1
                        End If
            If L1(6).Caption = "●" Then
            num3 = num3 + 1
            End If
           If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(10).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(15).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(16).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
         If num3 <> 0 Then
        L1(num).Caption = num3
        End If
'********************************************************************
   Case 12
   num3 = 0
            If L1(6).Caption = "●" Then
                        num3 = num3 + 1
                        End If

            If L1(7).Caption = "●" Then
            num3 = num3 + 1
            End If
           If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
           If L1(11).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(13).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(16).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(18).Caption = "●" Then
            num3 = num3 + 1
            End If
         If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
   Case 13
    num3 = 0
            If L1(7).Caption = "●" Then
                        num3 = num3 + 1
                        End If
              If L1(8).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(9).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(14).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(18).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(19).Caption = "●" Then
            num3 = num3 + 1
            End If
     If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '****************************************************************
   Case 14
   num3 = 0
        If L1(8).Caption = "●" Then
                  num3 = num3 + 1
                  End If
       If L1(9).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(13).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(18).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(19).Caption = "●" Then
        num3 = num3 + 1
        End If
     If num3 <> 0 Then
        L1(num).Caption = num3
        End If
'****************************************************************
   Case 15
   num3 = 0
        If L1(10).Caption = "●" Then
                  num3 = num3 + 1
                  End If
        If L1(11).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(16).Caption = "●" Then
        num3 = num3 + 1
        End If
      If L1(20).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(21).Caption = "●" Then
        num3 = num3 + 1
        End If
   If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '****************************************************************
  Case 16
   num3 = 0
            If L1(10).Caption = "●" Then
                        num3 = num3 + 1
                        End If
             If L1(11).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(15).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
              If L1(20).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(21).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(22).Caption = "●" Then
            num3 = num3 + 1
            End If
           If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
   Case 17
    num3 = 0
            If L1(23).Caption = "●" Then '错位了一个
                        num3 = num3 + 1
                        End If

          If L1(11).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(12).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(13).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(16).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(18).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(21).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(22).Caption = "●" Then
            num3 = num3 + 1
            End If
                  
    If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
   Case 18
num3 = 0
            If L1(12).Caption = "●" Then
                        num3 = num3 + 1
                        End If

            If L1(13).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(14).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(19).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(22).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(23).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(24).Caption = "●" Then
            num3 = num3 + 1
            End If
        If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
   Case 19
   num3 = 0
        If L1(13).Caption = "●" Then
                  num3 = num3 + 1
                  End If
        If L1(14).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(18).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(23).Caption = "●" Then
        num3 = num3 + 1
        End If
         If L1(24).Caption = "●" Then
        num3 = num3 + 1
        End If
      If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
    Case 20
    num3 = 0
        If L1(15).Caption = "●" Then
          num3 = num3 + 1
          End If
                If L1(16).Caption = "●" Then
                    num3 = num3 + 1
                    End If
                     If L1(21).Caption = "●" Then
                        num3 = num3 + 1
                        End If
         If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
    Case 21
   num3 = 0
        If L1(15).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(16).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(20).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(22).Caption = "●" Then
            num3 = num3 + 1
            End If
         If num3 <> 0 Then
        L1(num).Caption = num3
        End If
 '****************************************************************
    Case 22
   num3 = 0
        If L1(16).Caption = "●" Then
            num3 = num3 + 1
            End If
            If L1(17).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(18).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(21).Caption = "●" Then
            num3 = num3 + 1
            End If
             If L1(23).Caption = "●" Then
            num3 = num3 + 1
            End If
If num3 <> 0 Then
        L1(num).Caption = num3
        End If
'****************************************************************
    Case 23
  num3 = 0
       If L1(17).Caption = "●" Then
        num3 = num3 + 1
        End If
        If L1(18).Caption = "●" Then
         num3 = num3 + 1
         End If
            If L1(19).Caption = "●" Then
          num3 = num3 + 1
          End If
          If L1(22).Caption = "●" Then
         num3 = num3 + 1
         End If
          If L1(24).Caption = "●" Then
         num3 = num3 + 1
         End If
 If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  Case 24
   num3 = 0
      If L1(18).Caption = "●" Then
       num3 = num3 + 1
       End If
           If L1(19).Caption = "●" Then
               num3 = num3 + 1
               End If
                     If L1(23).Caption = "●" Then
                       num3 = num3 + 1
                       End If
        If num3 <> 0 Then
        L1(num).Caption = num3
        End If
  '****************************************************************
End Select
          
End Sub
Private Sub BeginGame()
Lblinfo.Caption = ""
j = 0 '一定要有,否则会出错!
num2 = 5
num4 = 5

lblnum2.Caption = num2
 For i = 0 To L1.Count - 1
     L1(i).Caption = ""
     C1(i).Visible = True
     C1(i).Caption = ""
     If i Mod 2 = 0 Then
         L1(i).BackColor = &H808080
         L1(i).BorderStyle = 1
       Else
         L1(i).BackColor = &HFFC0C0
         L1(i).BorderStyle = 1
       End If
 Next i
 
 Do '我这里面不用for就是确保雷的个数
    Randomize '随机产生5个雷,放于L1标签中的caption
    k = Int(Rnd * 25) '将k定位于0到24
    If L1(k).Caption = "" Then
          L1(k).FontSize = 21 '外设,大小和颜色
          L1(k).ForeColor = &HC0&
          L1(k).Caption = "●"
         j = j + 1
     End If
 Loop Until j >= 5
 
End Sub

Private Sub Check()
C1(num).Visible = 0
If L1(num).Caption = "●" Then
    Lblinfo.Caption = "你输了!"
    L1(num).BackColor = &H8080FF
        check3 '这是我后来加的,在输了这后,显示正确的答案!
  Else
   Call check2
  End If
 
End Sub
Private Sub C1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim stra As String
 If Button = 2 Then
 stra = C1(Index).Caption
    Select Case stra
      Case ""
        C1(Index).Caption = "雷"
        num2 = num2 - 1: lblnum2.Caption = num2
        If L1(Index).Caption = "●" Then
          num4 = num4 - 1
         End If
        If (num4 = 0 And num2 = 0) Then
                Lblinfo.Caption = "你赢了!"
             For i = 0 To C1.Count - 1
                 C1(i).Enabled = False
             Next i
        End If
      Case "雷"
         C1(Index).Caption = "?"
         num2 = num2 + 1 '前面一次标签上显示的一定是“雷”,故加1,而不是不变
          lblnum2.Caption = num2
                  If L1(Index).Caption = "●" Then '这里一定要有这一句,认为不是雷,就让其再返回去,即加1,我不会表达这句意思!
                     num4 = num4 + 1
            End If
     Case "?"
         C1(Index).Caption = ""
   End Select
   
 ElseIf (Button = 1) And (C1(Index).Caption = "") Then
    num = Index
   Call Check
    End If
  
End Sub
Private Sub cmdreplay_Click()
        For i = 0 To C1.Count - 1
            C1(i).Enabled = True
        Next i
    cmdreplay.Caption = "重玩"
   Call BeginGame
   
    
End Sub
Private Sub Form_Load()
    Form1.Left = Screen.Width * 0.618 - Me.Width / 2 '黄金分割点是其初始位置中心
    Form1.Top = Screen.Height * (1 - 0.618) - Me.Width / 2
        For i = 0 To C1.Count - 1
            C1(i).Enabled = False
        Next i
        Call BeginGame
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值