Solved

Need VB6 DELAY func/sub to delay hundreths of a sec

Posted on 2006-06-17
4
992 Views
Last Modified: 2012-05-05
Tho old dos PowerBasic had a DELAY stmt whose only operand was 'seconds.hundredths'. I need one for VB6. It's application is for slowing down pixel setting so you can see each pixel as it is set. Without a machine-independent delay its a blur. The pixels are rendering geometric equations.
0
Comment
Question by:shifty12
[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
4 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 16927088
sleep(1)
0
 
LVL 13

Accepted Solution

by:
Mark_FreeSoftware earned 125 total points
ID: 16927322
with this declaration:

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

and the above statement you have a delay
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16928041
The "Sleep()" API routine suspends all use of the application for the specified duration of time.

If you fancy trawling through a PAQ that I contributed to (although I don't recommend you do as it was quite a headache!):

"Setting VB code to listen on com port for input"
[ http://www.experts-exchange.com/Applications/MS_Office/Excel/Q_21582596.html ]

Here you'll find alternate code I provided to replace the Sleep() API call [using the same syntax, so interchangeable] that allows the use of the application (for example, minimizing, closing, moving the main window, etc) during the "pause" routine:

Private Function Sleep(ByVal lngMilliseconds As Long)

' Stub routine to call Pause() instead of "Sleep()" API...

  On Error Resume Next
 
  Call Pause(CDbl(lngMilliseconds / 1000&))
 
End Function
Private Function dblTimeStamp(Optional ByVal dblSeconds As Double = 0#) As Double

  On Error Resume Next
 
  dblTimeStamp = CDbl(Int(Now()) + (Timer + dblSeconds) / 86400)    ' 86400 = 60 seconds * 60 minutes * 24 hours
 
End Function
Private Sub Pause(ByVal dblSeconds As Double)

  Dim blnWend                                           As Boolean
  Dim dblTime                                           As Double
 
  On Error Resume Next
 
  dblTime = dblTimeStamp(dblSeconds)
 
  blnWend = (dblTimeStamp >= dblTime)
 
  While Not (blnWend)
 
      DoEvents
     
      blnWend = (dblTimeStamp >= dblTime)
     
  Wend
 
End Sub


BFN,

fp.
0
 
LVL 10

Expert Comment

by:fostejo
ID: 16929272
shifty12,

Following on from fanpages' post, the similar routine I usually use is:

Function Pause(tmpSeconds As Single)
    t = Timer
    While t + tmpSeconds > Timer
        DoEvents
    Wend
End Function

This, again, allows the application to be used as normal rather than 'suspending' it.

cheers
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

719 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