Click to See Complete Forum and Search --> : Wait function


akhileshk
May 11th, 2001, 12:39 PM
Hi all,
I was wodering if there is any function in VBScript Which does same thing As Sleep(xxx)(in VC++).
Or any thing I can force, so that system let me know that
xxx amout of time has elapsed. I don't want Busy loop.

HElp appreciated
Akhilesh

John G Duffy
May 11th, 2001, 12:55 PM
There is a "Sleep" API which suspends your APPs execution for the specified period of time. Here is a sample

' Following is the "Sleep" command
' General declaration section
option Explicit
private Declare Sub sleep Lib "Kernel32" Alias "Sleep" ( _
byval dwMilliseconds as Long)

private Sub Command1_Click()
Picture1.Cls
Picture1.print now " sleeping for 10 seconds"
sleep (10000)
Picture1.print now " Sleep finished"
End Sub




John G

akhileshk
May 11th, 2001, 01:24 PM
This function give run time error when i try to run the script. Here is the portion of Script, to
let you know how I am using it. Any suggestion


The Error is "expected End of Statement".
for one of those 2 lines of your code.
Since, I am not a Scripting Guy I could not figure it out.

Thanks

<SCRIPT LANGUAGE="VBScript">
option Explicit
private Declare Sub sleep Lib "Kernel32" Alias "Sleep" ( _byval dwMilliseconds as Long)

Sub Stream10()
Dim trackNum
trackNum = CLng(ReadOut.value)
LAPlaybackStream.Play(trackNum)
sleep(40000)
End Sub

</SCRIPT>

coolbiz
May 11th, 2001, 03:19 PM
The reply is for VB programming and not VBScript. If you're doing HTML coding, then use the Windows Scripting Object (of course if you client is on MS Windows Platform only) such as:

<script language="VBScript">
Sub Stream10()
Dim trackNum
trackNum = CLng(ReadOut.value)
LAPlaybackStream.Play(trackNum)

' Note that WScript is an already defined object when you're using scripting.
WScript.Sleep(40000)
End Sub
</script>

-Cool Bizs

John G Duffy
May 11th, 2001, 06:24 PM
I am not a script person either. Try getting rid of thet underscore in front of byval. Underscore is a continuation character breaking a line into two pieces. The statement should read:

private Declare Sub sleep Lib "Kernel32" Alias "Sleep" ( _
byval dwMilliseconds as Long)
'
'
' OR
private Declare Sub sleep Lib "Kernel32" Alias "Sleep" ( byval dwMilliseconds as Long)




John G