| | | 
Forum Member
       
Group: Forum Members Last Login: 9/12/2004 12:29:00 PM Posts: 42, Visits: 1 |
| is there any sort of cammnd to make a program wait a given time, like pause 5 to pause 5 seconds or like wait, or sumthing, i just need the program to "wait"
thnx t1n |
| | | | Forum God
       
Group: Forum Members Last Login: 3/13/2006 2:34:13 AM Posts: 794, Visits: 338 |
| hi T1N, 'Delay 5 seconds ' use : ' show a splash screen or process something here Call Delay(5) ' Unload your Splash screen here, or pick up where processing something has finished -and you know it won't take more than delay time passed as arg. 
Sub Delay(dblSecs As Double) Const OneSec As Double = 1# / (1440# * 60#) Dim dblWaitTil As Date
dblWaitTil = Now + OneSec * dblSecs Do Until Now > dblWaitTil DoEvents ' Allow windows messages to be processed Loop
End Sub
I have tested this sub (from EE) site and have used many times.
|
| | | | Forum God
       
Group: Forum Members Last Login: Today @ 4:38:01 AM Posts: 886, Visits: 5,287 |
| Often times there is more than one way to do things. Here is an API solution. Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Command1_Click() MsgBox "The back color of the form will change 5 seconds after you close this message box." Sleep 5000 Me.BackColor = vbBlue End Sub |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 11/5/2004 5:14:00 PM Posts: 5, Visits: 1 |
| Here is a very simple method I've used quite a bit. add a timer to your Form and set it's duration to 60000, then add this Sub.
Public Sub Pause(duration As Long) Dim Current As Long Current = Timer Do Until Timer - Current >= duration DoEvents Loop End Sub
Now, whenever you want something to Pause for a certain amount of time just write. Pause whatever ** Example **
Private Sub Command1_Click() MsgBox "This will Pause for 3 seconds.", vbExclamation, "3 Second Pause." Pause 3 MsgBox "This will Pause for 2 seconds.", vbExclamation, "2 Second Pause." Pause 2 MsgBox "This will Pause for 1 seconds.", vbExclamation, "1 Second Pause." Pause 1 MsgBox "Pause Demo Complete.", vbExclamation, "Pause Demo Complete." End Sub
It's really easy. Good Luck |
| | | | 
Forum God
       
Group: Forum Members Last Login: 2/1/2007 4:31:22 AM Posts: 656, Visits: 13 |
| Set the interval to 1000 not 60000. 1000 = 1sec 60000 = 1min. Just thought I'd point that out. James

 |
| | | | 
Forum Guru
       
Group: Forum Members Last Login: 5/20/2006 7:21:20 PM Posts: 189, Visits: 25 |
| wow-2 questions in a row have helped me.(including this 1)
DOS
 email me |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 6/5/2007 11:59:29 AM Posts: 1, Visits: 1 |
| I think that God's initial post is the best way but here is a revised version that will work with .NET 2005 (Newer versions of .NET do not like Now + OneSec, you must use the Now.AddSeconds(OneSec). Also you need to instantiate DoEvents you can't just call it any longer. Use Application.DoEvents() Sub Delay(ByVal dblSecs As Double) Const OneSec As Double = 1.0# / (1440.0# * 60.0#) Dim dblWaitTil As Date Now.AddSeconds(OneSec) dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs) Do Until Now > dblWaitTil Application.DoEvents() ' Allow windows messages to be processed Loop
End Sub |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 9/24/2008 8:16:21 PM Posts: 2, Visits: 2 |
| | Sub Delay(), written by Newbie, works for me, but it has brought back that dreaded, "beep", that I have only just learned to suppress in my Text1.KeyDown Subroutine using, eventArgs.SuppressKeyPress = Trueis the beep inevitable? My application performs a calculation when the user presses the "Enter" key. However, the calculation and posted anwer is performed so quickly, the user might not be sure it has been done correctly. So I want to change the font colour in the answer box to another colour for about 1/10th of a second, to give the impression of a quich flash, indicating to the user that the calculation has been done. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 9/24/2008 8:16:21 PM Posts: 2, Visits: 2 |
| | Sorry, my first time. That "Newbie" would be "skizznott". Its a pity that one can't view the previous postings when writing a reply. |
| | | | 
Forum God
       
Group: Forum Members Last Login: Today @ 8:45:13 AM Posts: 349, Visits: 1,705 |
| DavidKennedy (9/24/2008)
Sorry, my first time. That "Newbie" would be "skizznott". Its a pity that one can't view the previous postings when writing a reply. Yes, unlike other VB forums A1 won't let you scroll through all the other posts in the thread while Quoting or Replying. When clicking 'Quote Posted Reply' it will insert the text of that single post within your reply. To see all of the posts I usually open another IE tab as a work around. 
"So much to learn. So little time to do it. Wise men know it's later than one thinks"! ***Vote here to make Keith a Moderator*** http://www.a1vbcode.com/vbforums/FindPost23630.aspx |
| |
|
|