?
Solved

how to delay time in  a looping process ?

Posted on 2003-03-02
7
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 53

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
Technology Partners: 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 53

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 53

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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, 20 hours left to enroll

770 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