Author Topic: display time in label  (Read 745 times)

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
display time in label
« on: July 20, 2017, 11:55:04 PM »
Hello Archie, I am trying to display a time that shows just the Minutes:Seconds:Milliseconds in a label.  So far this code shows HH:mm:ss:ffff and I only want to remove the hours and only two places on the milliseconds.  I am using two TimeStampLabel controls and taking the time span between the two as shown below.  Just not sure how to trim off the excess and only show mm:ss:ff  How can I do this?  thank you.

   
    Private Sub tslOnEmer_ValueChanged(sender As Object, e As EventArgs) Handles tslOnEmer.ValueChanged
        Dim difference As TimeSpan = DateTime.Parse(tslOnEmer.Text) - DateTime.Parse(tslLossOfNorm.Text)
        lblTimeDiff.Text = difference.ToString()

    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
    • View Profile
    • AdvancedHMI
Re: display time in label
« Reply #1 on: July 21, 2017, 05:11:35 AM »
I'm thinking it is something like this:

difference.ToString("mm\:ss\:ff")

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: display time in label
« Reply #2 on: July 21, 2017, 08:27:08 AM »
Ah yes. I was close. I didn't have the backslashes which caused it to crash. Works great now, thanks!!