Playing multiple files from array
I'm trying to make a "Simon" game with four buttons labeled 1-4. The game is supposed to read the numbers out loud, but i have a problem with that. I have 4 wav files from google text-to-speech, each named 1-4. I made an number generator that can return like this "42331", and the game is supposed to play 4.wav, 2.wav, 3.wav, 3.wav and 1.wav.
Here's what i got so far.
Code:
Public Class Form1
Dim rnd As New Random
Dim i = 0
Dim level As Integer = 5
Dim nums As String
Dim ns
Dim pla As New System.Media.SoundPlayer
Function gsa()
Dim h
While i < level
h = Math.Round(rnd.NextDouble * 4)
If h = 0 Then
h = 1
End If
nums = nums + h.ToString
i = i + 1
End While
MsgBox(nums)
Return nums
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ns = gsa()
i = 0
While i > level
pla.SoundLocation = ns(i) + ".wav"
pla.Play()
i = i + 1
End While
End Sub
End Class
It reads nothing.
If i try with
Code:
Imports System.Threading.Thread
Public Class Form1
Dim rnd As New Random
Dim i = 0
Dim level As Integer = 5
Dim nums As String
Dim ns
Dim pla As New System.Media.SoundPlayer
Function gsa()
Dim h
While i < level
h = Math.Round(rnd.NextDouble * 4)
If h = 0 Then
h = 1
End If
nums = nums + h.ToString
i = i + 1
End While
MsgBox(nums)
Return nums
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ns = gsa()
For Each num In ns
pla.SoundLocation = ns(num) + ".wav"
pla.Play()
i = i + 1
Next
End Sub
End Class
It only plays 1.wav (the last in the sequence)
I'm new to this forum so please help.
Re: Playing multiple files from array
Re: Playing multiple files from array
Re: Playing multiple files from array
Re: Playing multiple files from array