Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to delay time in  a looping process ?

Posted on 2003-03-02
7
Medium Priority
?
201 Views
Last Modified: 2010-05-01
I have a for loop routine which i want it to puawse for 2 second before it go to the next loop:


For i = 1 to 10

WSockServer(1).SendData "ABC"

'I want the program to pause for 2 second here before
it proceed with the next  i

next i

Someone please help.
0
Comment
Question by:netcool
  • 3
  • 2
  • 2
7 Comments
 
LVL 55

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 8054512
Try use the Sleep API:

Example:

'This project needs a button
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Me.Caption = "Your system will sleep 5 sec."
    'Sleep for 5000 milliseconds
    Sleep 5000
    Me.Caption = ""
End Sub
Private Sub Form_Load()
    Me.Caption = ""
    Command1.Caption = "Sleep ..."
End Sub

cheers
0
 
LVL 1

Expert Comment

by:Smashmad
ID: 8054524
HI, try that:


'----------------------

dim startTime as single

For i = 1 to 10

WSockServer(1).SendData "ABC"

  starttime = Timer
  do
  doevents
  loop while Timer - startTime < 2 'number of seconds

next i
0
 
LVL 5

Author Comment

by:netcool
ID: 8054883
both source work perfectly good for me. How may i give points to both of you for your effort. Please advice.TQ
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Expert Comment

by:Ryan Chong
ID: 8054920
Try post a o pts question at: Communty Support, and ask for Split point for question Q_20535835.

http://www.experts-exchange.com/Community_Support/

cheers
0
 
LVL 1

Expert Comment

by:Smashmad
ID: 8054956
Give ryancys the points, he answered first.
0
 
LVL 5

Author Comment

by:netcool
ID: 8055102
I will give ryancys points as suggested Smashmad here. Thank you so much.
0
 
LVL 55

Expert Comment

by:Ryan Chong
ID: 8055264
okok, thks. Please PAQ this question.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question