Results 1 to 5 of 5

Thread: Creating a kind of clock in VB6

  1. #1
    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.

  2. #2
    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.

  3. #3
    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 ...)

  4. #4
    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?

  5. #5
    Join Date
    Jan 2006
    Posts
    211

    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?
    No, DateDiff is a function VB6 standard. Very strange as error ...
    Sure I did everything as in?

Similar Threads

  1. What all different kind of pen you are using on Asus EA800?
    By DougWison in forum Portable Devices
    Replies: 4
    Last Post: 10-08-2011, 08:42 PM
  2. What kind of user needs SAN
    By Sharanya in forum Networking & Security
    Replies: 5
    Last Post: 18-03-2010, 03:02 AM
  3. Is ±±±±±±±±.±±± some kind of a virus??
    By Bansi_WADIA in forum Networking & Security
    Replies: 3
    Last Post: 20-11-2009, 06:27 AM
  4. Replies: 3
    Last Post: 22-07-2009, 09:14 PM
  5. What kind of processor do you buy?
    By manishdk in forum Polls & Voting
    Replies: 1
    Last Post: 15-12-2008, 07:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,886,288.84053 seconds with 16 queries