好的,所以我使用 Visual Studio 2010 几乎完善了一款名为lucky 7 的游戏。我想在赢得游戏时播放声音(在三个插槽之一中获得 7)。这是代码:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For i = 0 To 2
slots(i) = rand.Next(10)
Next
Label1.Text = (slots(0).ToString)
Label2.Text = (slots(1).ToString)
Label3.Text = (slots(2).ToString)
If slots(0) = 7 Or slots(1) = 7 Or slots(2) = 7 Then
score = score + 100 'REM 10 points for each win
Label4.Text = (score.ToString)
PictureBox1.Visible = True 'REM If you have a PictureBox
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV",
Else
PictureBox1.Visible = False
End If
If score = 500 Then
MsgBox("You Scored 500 Points!", vbInformation)
End If
End Sub
问题是,我在“playsound”语句中遇到错误,我真的很想在玩家赢得比赛时播放那个声音!
我还尝试创建一个重置按钮,它将分数和所有三个插槽设置回 0,但是当我单击它时,什么也没有发生。这是重置按钮的代码:
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
score = 0
PictureBox1.Visible = False
End Sub