-1

-我是 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
4

1 回答 1

4

在 VB6 中,事件处理程序采用 SourceObject_EventName 的形式。您的 MouseDown 不符合此规定。

于 2012-06-10T00:50:25.617 回答