VB6 - 游戏不起作用

时间:2012-06-09 00:21:47

标签: vb6

- 我是VB6的菜鸟,我只需要知道我在代码中做错了什么 我想让鼠标依次单击表格中的图片框 根据具体情况执行代码

这是我的代码:

Dim MineTotalHits As Integer
Dim MineTotal As Integer
Dim EmptySquare As Integer
Dim MineTotalMisses As Integer
Dim WinSnd As Boolean
Dim MinesInRow As Integer
Dim ShellCount As Integer
Dim MaxMines As Integer
Dim MinesLeft As Integer

Private Sub Form_Load()
    Snd.Hide
    Start.Show

    Dim Count(1 To 10) As Integer
    Dim RowMines(1 To 10) As Label

    EmptySquare = 50
    MaxMines = 50
    ShellCount = 90
    MinesLeft = 50
    MineTotal = 0
    MineTotalHits = 0
    MineTotalMisses = 0

    Do Until MineTotal = MaxMines
        Randomize (Int(99 * Rnd + 1))
        MineTotal = MineTotal + 1
    Loop      
End Sub


Public Sub WinGame(WinSnd As Boolean)
    Dim IntResponse As Integer

    If MinesLeft = 0 Then
        WinSnd = True
        MsgBox ("You have won the Game")
        IntResponse = MsgBox("Would You like to play a New Game?", vbYesNo Or vbQuestion, "NewGame?")

        If IntResponse = vbYes = 1 Then
            Snd.Show
        ElseIf IntResponse = vbNo = 2 Then
            Unload Me
        End If

    ElseIf ShellCount = 0 Then
        WinSnd = False
        MsgBox ("You have lost the Game")
        IntResponse = MsgBox("Would you Like to play a New Game?", vbYesNo Or vbQuestion, "NewGame?")

        If IntResponse = vbYes = 1 Then
            Snd.Show
        ElseIf IntResponse = vbNo = 2 Then
            Unload Me
        End If
    End If
End Sub


Private Sub Picture1_Click(Index As Integer)
    Dim Picture1(99) As PictureBox
End Sub

Private Sub MouseDown(Button As Integer, Index As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then Call MouseDown
        If Picture1(99) = MinesLeft Then
            MsgBox ("You have destroyed a mine")
            MineTotalHits = MineTotalHits + 1
            MinesLeft = MinesLeft - 1
            Picture1(Index).BackColor = vbBlack

        ElseIf Picture1(99) = EmptySquare Then
            MsgBox ("You have missed a mine")
            EmptySquare = EmptySquare - 1
            MineTotalMisses = MineTotalMisses + 1
            Picture1(Index).BackColor = vbRed
        End If
    End If
End Sub


Private Sub MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Picture1().BackColor = vbBlack Or Picture1().BackColor = vbRed Then
        MsgBox ("This Square has already been hit")

    Exit Sub
End Sub

1 个答案:

答案 0 :(得分:4)

在VB6中,事件处理程序采用SourceObject_EventName的形式。你的MouseDown不符合这一点。