大家好,我有一個在vb.net中製作的賓果遊戲。我的聲音記錄在我的D:文件夾中。我每次播放一個數字和字母時都會播放它,但是每當我關閉遊戲窗體然後從菜單中再次開始一個新遊戲,聲音就不再播放了。該程序確實經歷了我製作的聲音功能但它不會播放聲音。這裏是我的代碼:重新打開表單時聲音不會彈出
Sub sound()
If lblletter.Text <> "" And lblNumber.Text <> "" And lbllang.Text = "English" Then
Dim sound As String = "D:\BINGO BONANZA\ENGLISH\" + lblletter.Text + " " + lblNumber.Text + ".wav"
If My.Computer.FileSystem.FileExists(sound) Then
My.Computer.Audio.Play(sound, AudioPlayMode.Background)
Else
MsgBox("No sound file for this")
End If
ElseIf lblletter.Text <> "" And lblNumber.Text <> "" And lbllang.Text = "English" Then
Dim sound As String = "D:\BINGO BONANZA\FILIPINO\" + lblletter.Text + " " + lblNumber.Text + ".wav"
If My.Computer.FileSystem.FileExists(sound) Then
My.Computer.Audio.Play(sound, AudioPlayMode.Background)
Else
MsgBox("No sound file for this")
End If
End If
End Sub
它將永遠不會進入else if塊,因爲它具有與第一個條件相同的條件。另外,在那裏放置一個斷點,看看發生了什麼。逐行瀏覽它,看看是否有任何東西突然出現在你身上。 –
我已經解決了我的問題..它不需要對我的代碼做任何事情。 :) – Ley47