Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-04-2009
Member
 
Join Date: Apr 2009
Posts: 55
Creating a kind of clock in VB6

Hello everyone, I'm trying to create a program in visual basic 6 that when you clicked the button "Start" begins to count the time (hh-mm-ss) and at the same time, starting from 14m and 59s, I stop that time up to 0m and 0s where, at that point, an increase of one meter, and again the time to climb from 0. I managed to write a great piece of code and runs so good ...... for the first 5 / 6 minutes, after which the time begins to have less than 2 seconds, and the countdown of 15m to be over 2 seconds the normal (I used a stopwatch to check). I tried a couple of solutions but the code seem right way. So I ask you experts if you can solve this problem. Or if you know another way to build this program.

If you wanted to see the code here i have written it.Please go through it.
Reply With Quote
  #2  
Old 24-04-2009
Member
 
Join Date: Jan 2009
Posts: 143
Re: Creating a kind of clock in VB6

Hello, I think the problem is due to the fact that the timers are not perfect in the sense that if you put a timer that fires every second in this reality triggered at times after 1000 ms, sometimes after 1002 ms, and so forth. There is a margin of error. For a program of this kind should in sync with the system clock. I do not know how to do it in VB6, you should still search for information in this regard.
Reply With Quote
  #3  
Old 24-04-2009
Member
 
Join Date: Jan 2006
Posts: 211
Re: Creating a kind of clock in VB6

Small example: we have a simple form with this code:

Code:
  Private startDate As Date 
  Private secAuto As Integer 
  Private secSys As Integer 

  Private Sub cmd_start_Click () 
      secAuto = 0 
      secSys = 0 
      startDate = Now 
      Timer_auto.Enabled = True 
      Timer_sys.Enabled = True 
  End Sub 

  Private Sub Timer_auto_Timer () 
      secAuto = secAuto + 1 
      lbl_auto.Caption = secAuto 
  End Sub 

  Private Sub Timer_sys_Timer () 
      secSys = DateDiff ( "s", startDate, Now) 
      lbl_sys.Caption = secSys 
  End Sub
Timer_auto mark time "for her", the marks Timer_sys while interrogating every second the system date. Within the first 3 minutes the two timers have a difference of 1 second.
If you want to be always synchronized with the system using the second method (Timer_sys). Furthermore, it is not necessary to hold the 1000 range of Timer_sys, but since the increase is always done on a comparison with the timer system, you can use more specific intervals (50 ...)
Reply With Quote
  #4  
Old 24-04-2009
Member
 
Join Date: Apr 2009
Posts: 55
Re: Creating a kind of clock in VB6

ah, thank you very much I understood..

But I never used the DateDiff does, in fact if I make a form like the one showing you mistake me. Not that I have to make some API to use DateDiff?
Reply With Quote
  #5  
Old 24-04-2009
Member
 
Join Date: Jan 2006
Posts: 211
Re: Creating a kind of clock in VB6

Quote:
ah, thank you very much I understood..

But I never used the DateDiff does, in fact if I make a form like the one showing you mistake me. Not that I have to make some API to use DateDiff?
No, DateDiff is a function VB6 standard. Very strange as error ...
Sure I did everything as in?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Creating a kind of clock in VB6"
Thread Thread Starter Forum Replies Last Post
What all different kind of pen you are using on Asus EA800? DougWison Portable Devices 4 10-08-2011 08:42 PM
What kind of user needs SAN Sharanya Networking & Security 5 18-03-2010 03:02 AM
Is ????????.??? some kind of a virus?? Bansi_WADIA Networking & Security 3 20-11-2009 06:27 AM
Error 'This server's clock is not synchronized with the primary domain controller's clock' Akiraa Networking & Security 3 22-07-2009 09:14 PM
What kind of processor do you buy? manishdk Polls & Voting 1 15-12-2008 07:53 PM


All times are GMT +5.5. The time now is 03:08 AM.