Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > How to use Timer??


Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2002, 03:29 AM
pip187
Guest
 
Posts: n/a
Question How to use Timer??


How do I use the timer to make a pause in an event?

I have put a timer on my form, and assigned an interval of 10000.

I want to use the timer in my code, so when I click cmdChange, the code is executed up to a certain point, and then there is a 10 second pause before the rest of the code is executed.

eg.
Private Sub cmdChange_Click()
frmTest.print "Please wait 10 seconds"
(10 second pause required)
frmTest.print "thanks for waiting"
End Sub

Thanks

Phil.
Reply With Quote
  #2  
Old 03-04-2002, 03:59 AM
Banjo's Avatar
Banjo Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

You need either a DoEvents loop:
Code:
Do Until bTimerDone
    DoEvents
Loop
Where you set the module level variable bTimerDone to true in the timers event.
Or you can call the second half of the code directly from the timers events.
I personally prefer the first method.
__________________
A wise one man once said "what you talking about dog breath"
Reply With Quote
  #3  
Old 03-04-2002, 06:13 AM
Anis's Avatar
Anis Anis is offline
| Coder XXX |

Retired Leader
 
Join Date: Jun 2001
Location: Kuala Lumpur, Malaysia.
Posts: 3,018
Default

Use the following function...

Code:
Sub Wait(ByVal s As Integer)
Dim t As Double
t = Now() + s / 86400#
While t > Now()
DoEvents
Wend
End Sub
If you want a delay of one second..

Code:
wait(1)
__________________
Regards,
Muhammad Anis Ur Rehman

Miles to go Before I Sleep.

http://www.projekcarpet.com/anis.html
Reply With Quote
  #4  
Old 03-04-2002, 10:35 AM
ChiefRedBull's Avatar
ChiefRedBull ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

My personal favourite - the Sleep API.
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->