2 Replies - 3824 Views - Last Post: 17 August 2010 - 11:41 AM Rate Topic: -----

#1 dtvonly  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 31-January 10

how to count seconds tick...

Posted 12 August 2010 - 06:25 AM

I am using (in VB6) the Timer1 function to read data in at 10 seconds interval. How do I continue to display the seconds in a text box before the 10 seconds interval is reached? Example:

1,2,3,4,5,6,7,8,9,10 --> collects data
11,12,13,14,15,16,17,18,19,20 --> collects data
21,22,23,24,25,26,27,28,29,30 --> collects data

and so on...

with each second being display in a text box as: Time Elapsed: x seconds (where x starts with 1).

thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: how to count seconds tick...

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: how to count seconds tick...

Posted 17 August 2010 - 09:15 AM

Firstly, you need to be aware that the timer isn't 100% accurate, so as long as you're OK with that then you could try something as follows:

1. configure the timer interval to be 1 second and add a textbox to your form.
2. declare a module wide variable and set its value to one on start up and display it in your textbox.
3. In the timer event you could code it to check if you where at a 10 second interval by using the mod function. So something like:

if (variable mod 10) = 0) then
    read data
endif



4. Ensure you increment the variable and update the textbox in the timer event also.


Hopefully that should give you a starting point.
Was This Post Helpful? 0
  • +
  • -

#3 kingsonprisonic  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 74
  • Joined: 09-July 09

Re: how to count seconds tick...

Posted 17 August 2010 - 11:41 AM

In vb timer 1 second = 1000 milisecond.

Here is a link of demo project Download.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1