Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27311

play different sounds from resources using dim string?

$
0
0
I have this code:
Code:

  For i As Integer = 1 To 4
            Dim btn As Control = Me.Controls("button" & i.ToString())
            bttn.Add(btn)
            Dim beepx As String = "My.Resources.beep" & i.ToString()
            beep.Add(beepx)
        Next
        If Form2.sound = True Then
       
            My.Computer.Audio.Play(beep(l), AudioPlayMode.Background)

        End If

the bp is a private array just like the bttn but the audio doesnt work. in the beep(l) the l represents a random number and it should work like this is the random number is 4

My.Computer.Audio.Play(My.Resources.beep4, AudioPlayMode.Background)

even though the beep(l) has the value of "My.Resources.beep4" it just gives an exeption on runtime, I figured it would be possible since the my.resources.beepX is the location as string.
does anyone know whats going on here?

Viewing all articles
Browse latest Browse all 27311

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>