Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:03:00+00:00 2026-06-11T13:03:00+00:00

Here I initialize the time variables to 0 and use StopWatch to count milliseconds

  • 0

Here I initialize the time variables to 0 and use StopWatch to count milliseconds and DispatcherTimer to update UI

Imports System.Threading
Imports Windows.UI.Xaml

Dim dt As DispatcherTimer = New DispatcherTimer
Dim dd As Integer = 0
Dim mm As Integer = 0
Dim hh As Integer = 0
Dim ss As Integer = 0
Dim ms As Integer = 0
Dim stopwatch As System.Diagnostics.Stopwatch = New System.Diagnostics.Stopwatch

Private Sub ontimertick()
        ms = stopwatch.ElapsedMilliseconds
        ss = ms / 1000
        ms = ms Mod 1000
        mm = ss / 60
        ss = ss Mod 60
        hh = mm / 60
        mm = mm Mod 60
        dd = hh / 24
        hh = hh Mod 24
        MicroSeconds.Text = ms.ToString("00")
        Seconds.Text = ss.ToString("00")
        Minutes.Text = mm.ToString("00")
        Hours.Text = hh.ToString("00")


    End Sub

Private Sub StartButton_Click(sender As Object, e As RoutedEventArgs) Handles StartButton.Click

dt.Interval = New TimeSpan(0, 0, 0, 0, 100)
AddHandler dt.Tick, AddressOf ontimertick
stopwatch.Start()
dt.Start()

End Sub

The problem is that the very first instance of all variables increment in 1/2 of the time than the actual time I expect.

e.g. seconds.text is updated to 1 on 500th ms and the next onwards after 1000ms

Similarly Minutes.text is updated to 1 after 30th second and after that it increments after 60 seconds as normal

Same with the hour and day but only for the very 1st instance after that it increments after the normal intervals

So can anyone help me finding out the logical error?


I am Wondering how can I Reverse the process and countdown the time?

Can you guys help me with Idea/Logic that i can implement?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:03:01+00:00Added an answer on June 11, 2026 at 1:03 pm

    I think you’re doing more work than you need to. The Stopwatch.Elapsed property returns a TimeSpan, which has all of the individual parts of the elapsed time.

    Your ontimertick() could look like this:

    Private Sub ontimertick()
        TimeSpan e = stopwatch.Elapsed
        MicroSeconds.Text = e.Milliseconds.ToString("00")
        Seconds.Text = e.Seconds.ToString("00")
        Minutes.Text = e.Minutes.ToString("00")
        Hours.Text = e.Hours.ToString("00")
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is some code: class Person def initialize(age) @age = age end def age
Here is my app.js: Ext.application({ views: ['SignIn'], launch: function() { // Initialize the signin
Here is the error: System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception. --->
I'm having a hard time understanding why this.$map and this.markers are undefined. Here's the
Loooong time viewer, finally getting round to signing up here at StackOverflow! After a
Several people have commented on my C code here, saying that I should use
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.