Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Timer to scroll a list box automatically 1

Status
Not open for further replies.
Joined
Jun 30, 2003
Messages
196
Location
GB
Hi all VB6 experts

Do any of you know how i could acheive the following functionality.

I have a list box, and i want the application to automatically scroll down the list box playing an associated wav file for each item (bassically the wav file reads out what the item says).

I believe the answer to my problem is to use the timmer and to use logic like after 4 seconds move to next item and play wav file (making sure i set the time long enough for the wav file to finish)

My question is however how do i implement this feature and incorporate the functionality into my application. I have never used a timer before so dont really know where to start.

thanks
Dan
 
Place a timer control onto your form. Set the interval to 500, which is half a second. You can set it to longer, but there is maximum which isn't very long, so you made need to include a myTime = myTime + 1 counter. When the counter gets to 16, 8 seconds, then reset the counter, and using an if statement, complete the rest of your code.

In terms of setting the listbox selected item, this can be done in code using list.selected(i)=true

In your timer sub, place:

myTimer = myTimer + 1

if myTimer > 8 then 'interval of 500, this is 4 seconds
myTimer = 0 'reset for next loop
if listbox.listIndex = (listbox.listcount-1) then 'last item is selected
listbox.selected(0) = true
else listbox.selected(listbox.listindex + 1) = true
end if
end if

BB
 
>there is maximum which isn't very long

Well, it's 65.535 seconds...
 
An alternative is, if you are using the PlaySound API to play the .wav files, that there is a calling argument for PlaySound that causes synchronous operation. PlaySound doesn't return control until the sound completes. Seems simpler than messing with timers and trying to guess how long the sound will play.
 
ok guys thanks for the great advice. I am going to try to use the timer method as i am planning on shipping my application to a mobile phone and i dont think it will support the playsound API, but thanks any way golom i remember that for next time.

Strongm Is the maximum 65 seconds or 65% of a second or somthing?

Biggerbrother your probably hear back from me as i am just about to start to try your solution.

Thanks again all of you.
 
Maximum value for Interval is 65535 and it's in milliseconds, so that equates to 65535 milliseconds or just over a minute, exactly as strongm says.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top