由于某些原因,当我尝试播放可变单词列表时,程序崩溃。我不明白为什么。
我已通过“ WordList.Add”添加到变量,并尝试播放(WordList(1))
我尝试进行故障排除未成功。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCheck.Click
While loopstart = 1
If txtEnter.Text = arrWords(word) Then 'If the text entered into the textbox is equal to the array word
MsgBox("You got the correct answer " & word & "/10") 'A msgBox will appear telling them they got it right and the point will be added to the total.
word = word + 1 'If word is correct, it'll go to the next word in the list
txtEnter.Clear() 'Clears the textbox
Else
MsgBox("This is incorrect, try again") 'Tells the user they failed and the user will have to reattempt untill correct
txtEnter.Clear() 'Clears the textbox
End If
Exit While 'Exits out of the loop
End While
End Sub
Private Sub BtnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
My.Computer.Audio.Play(WordList(1))
End Sub
Private Sub Fm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
arrWords(1) = "A"
arrWords(2) = "Any"
arrWords(3) = "Ask"
arrWords(4) = "Come"
arrWords(5) = "Go" 'An array of words being used(Dimed up top)
arrWords(6) = "He"
arrWords(7) = "No"
arrWords(8) = "Once"
arrWords(9) = "The"
arrWords(10) = "You"
word = 1
loopstart = 1 'Loop used in btnCheck
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\A.wav", 1)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\Any.wav", 2)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\Ask.wav", 3)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\Come.wav", 4)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\Go.wav", 5)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\He.wav", 6) 'Dictionary of words(Dimed up top) *Doesn't work
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\No.wav", 7)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\Once.wav", 8)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\The.wav", 9)
WordList.Add("E:\Scintillating spelling simulator\Audio Files\Year 1\You.wav", 10)
loopstart2 = 1
song = 1
关于我在做什么错的任何想法吗?
答案 0 :(得分:0)
确保初始化Dictionary properly
:
Private WordList As New Dictionary(Of String, Integer)