Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual Studio 2008 Timer Control  - Timer1_Tick

Posted on 2008-11-02
2
Medium Priority
?
8,535 Views
Last Modified: 2013-12-26
Hi

I have a timer control on a Windows form in Visual Studio 2008. I want the Timer1_Tick code
to run at the start of every minute. At the moment I have the Interval property set to 60000, but
the code runs based on when I enabled the Timer, eg 5 seconds after the start of every minute.
Is there a way to perhaps ensure that the timer gets enabled at the beginning of the new minute?
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 22865219
You can define at the beginning the exact interval to the right time and then you set 1 minute again-

Here's an example:

Public Class Form1
 
    Private WithEvents tm As Timer
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tm = New Timer
        tm.Interval = New TimeSpan(Now.Hour, Now.Minute + 1, 0).Subtract(Now.TimeOfDay).TotalMilliseconds
        tm.Start()
    End Sub
 
    Private Sub tm_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tm.Tick
        Me.tm.Interval = 60000
        Me.Label1.Text = DateTime.Now.ToLongTimeString
    End Sub
 
End Class

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 31512610
thanks very much
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question