Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2007, 09:37 AM
Authorized User
 
Join Date: Dec 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default function to display a countdown

hello,
I'm using the Sleep function currently in some VB code so my program stops and waits until whatever time I specify for it to, but the problem with Sleep, is the user of my program has no idea how much time has elapsed. What I'd like to do is instead have a fuction that I can pass to it the time in seconds that I want to elapse, then that function displays a small window that shows the time counting down second-by-second in real time and also has a button that when clicked stops the countdown and executes the function.
Could anyone share with me the code that would acomplish this?
thanks in advance,
david

 
Old February 14th, 2007, 10:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. what about using a timer control that refresh a textbox every second??



HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
 
Old February 14th, 2007, 10:04 AM
Authorized User
 
Join Date: Dec 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

gonzalo,
hello,
I'm relatively new to VB, how would I do that?
and
I did want to have the option of clicking a button and stopping the timer early.
thanks,
david

 
Old February 14th, 2007, 10:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

a timer control is one of the control you could add to your forms.

This one has only one relevant event that is raise every number of milliseconds (you decide when)...

for your case, and for the sake of simplicity, i would use a timer with his interval set to 1000 (that's 1 second), and display the remaining time...

when the user press the button you only has to disable the timer (set enable to false) and do whatever you want to...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
 
Old February 15th, 2007, 07:05 PM
Authorized User
 
Join Date: Dec 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you for your help,
I did figure out a solution from a posting on another website.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Decode function to display result in same row yogeshyl SQL Language 0 July 2nd, 2008 12:40 AM
Display function jianwei Visual C++ 0 June 18th, 2007 10:22 PM
Countdown Timer stalkingbutler Access VBA 2 April 16th, 2007 10:44 AM
Countdown kritimehrotra Access VBA 3 July 25th, 2006 02:55 PM
Function Display Problems??? webasp1 Classic ASP Databases 0 August 6th, 2003 03:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.