See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: VB headache  (Read 1310 times)

0 Members and 1 Guest are viewing this topic.

Offline UAF_Lt_Brenton

  • Full Member
  • ***
  • Posts: 231
  • Karma: 0
28 September 2004, 18:11:47
I need help with a program I'm building.  Any ideas how to get VB to pause for x milliseconds?

Quote
Private Sub Begin_click()
Voice.Speak "Test 1"
Voice.Speak "Test 2"
' Pause required here
Voice.Speak "Test 3"
End Sub

Any suggestions would be appreciated


================
LtBrenton

:hot: "Sir, we have a smiley blocking engine 3..."

David Fox

  • Guest
Reply #1 - 28 September 2004, 22:49:49
Well, Excel's VB has a function: Timer() that counts the number of seconds since midnight, resolved to 100th's of a
second. If you set a variable equal to Timer() and then do a loop while Timer()<variable+value, where value=desired
delay in seconds, then this should more or less do what you want, although good only to 100th's of a second, rather
than milliseconds.

Alternatively, you could just make the computer count for a while:

For i= 1 to n
Next i

where n is some number, determined experimentally, that produces the desired delay.



Offline DocHoliday

  • Legend
  • ******
  • Posts: 2475
  • Karma: 2
Reply #2 - 29 September 2004, 07:14:32
I don't know about VB, but in VBA (Basic for Office) the command would be Wait it's syntax is:

expression.Wait(Time)

Time given in seconds as duration.

Must be something similar in full VB. For loop or any kind of other loop works too. I assume you're inserting the delay
to make sure the previous sound is finished, before the new one starts, so I guess you could use a while loop that
would somehow check if the speaker is free or something like that. I'm pretty sure it can be done, although I don't
know how to offhand. Since you appear to be using some kind of speech synthesis, I think it's safe to assume there
are routines for precisely this purpose as part of the the speech synthesizer..

Cheers,


~~~

"Mood is a matter of choice. I choose to have fun!" -Vidmarism No 15

tony

  • Guest
Reply #3 - 26 October 2004, 01:27:19
d = 5
k = Timer
e = Timer + d
While Timer < e
    DoEvents
Wend

the 5 in the 1st line represents 5 seconds.  Change it to whatever you want, including fractions of a second.
the DoEvents statement prevents your computer from acting like it's locked up while the delay loop is running.

This method is better than the

for i=1 to n
next i

method, because that method will yield different delay results on different computers depending on processor speed
and other things.

« Last Edit: 26 October 2004, 01:27:19 by tony »