By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,696 Members | 2,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,696 IT Pros & Developers. It's quick & easy.

List Box Array and Sounds

P: 20
Hello... Currently I have an array of 8 listboxes in VB6. Each item in my listbox plays a wav sound from a large file on my desktop called "Sounds".

I am using the sndPlaySound API.

The code I have to link everything up is:


Private Sub List1_Click(Index As Integer)

Const sSoundFolder = "C:\Users\Chris\Desktop\Sounds\"
Dim sToneFile As String
Dim x%

If List1(n).ListIndex < 0 Then Exit Sub

sToneFile = sSoundFolder & List1(n).List(List1(n).ListIndex) & ".wav"
x% = sndPlaySound(sToneFile, SND_ASYNC Or SND_NODEFAULT)


End Sub

My items are entered like this:

List1(0).AddItem "Home 1"
List1(0).AddItem "Home 2"
List1(0).AddItem "Home 3"
...

List1(1).AddItem "Office 1"
List1(1).AddItem "Office 2"
...

List1(2).AddItem "School 1"
List1(2).AddItem "School 2"
List1(2).AddItem "School 3"
...


I now need to go into my desktop "Sounds" file on my desktop and organize things better. I will create folders inside the "Sounds" file called "Home", "Office", "School", and so on. I will move all wav files to their relative folders.

How can I update my code so that when a new listbox is active in my program the array will go to the different folders?

To link List1(0) with: "C:\Users\Chris\Desktop\Sounds\Home\"
To link List1(1) with: "C:\Users\Chris\Desktop\Sounds\Office\"
To link List1(2) with: "C:\Users\Chris\Desktop\Sounds\School\"
... ... ... all the way to List1(7)

Thanks for your help.
Mar 23 '08 #1
Share this Question
Share on Google+
1 Reply


VBWheaties
100+
P: 145
Hello... Currently I have an array of 8 listboxes in VB6. Each item in my listbox plays a wav sound from a large file on my desktop called "Sounds".

I am using the sndPlaySound API.

The code I have to link everything up is:


Private Sub List1_Click(Index As Integer)

Const sSoundFolder = "C:\Users\Chris\Desktop\Sounds\"
Dim sToneFile As String
Dim x%

If List1(n).ListIndex < 0 Then Exit Sub

sToneFile = sSoundFolder & List1(n).List(List1(n).ListIndex) & ".wav"
x% = sndPlaySound(sToneFile, SND_ASYNC Or SND_NODEFAULT)


End Sub

My items are entered like this:

List1(0).AddItem "Home 1"
List1(0).AddItem "Home 2"
List1(0).AddItem "Home 3"
...

List1(1).AddItem "Office 1"
List1(1).AddItem "Office 2"
...

List1(2).AddItem "School 1"
List1(2).AddItem "School 2"
List1(2).AddItem "School 3"
...


I now need to go into my desktop "Sounds" file on my desktop and organize things better. I will create folders inside the "Sounds" file called "Home", "Office", "School", and so on. I will move all wav files to their relative folders.

How can I update my code so that when a new listbox is active in my program the array will go to the different folders?

To link List1(0) with: "C:\Users\Chris\Desktop\Sounds\Home\"
To link List1(1) with: "C:\Users\Chris\Desktop\Sounds\Office\"
To link List1(2) with: "C:\Users\Chris\Desktop\Sounds\School\"
... ... ... all the way to List1(7)

Thanks for your help.
I'de use a collection or an array to store the paths relative to the index in the list.
Mar 24 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.