|
-
Jan 1st, 2004, 12:27 PM
#1
Thread Starter
Fanatic Member
Convert to minutes
A timer has been stopped at some point. The timer is in the form of 00:00:00-hrs mins, secs
how is it possible to take all of this, even if it has 10:14:29, and convert it to minutes?
i dont mind if it has something like 117.67 mins-thats even better.
can anyone help?
-
Jan 1st, 2004, 12:40 PM
#2
Frenzied Member
Seems like I'm on a TimeSpan kick these days - there are probably several ways to achieve the same results.
VB Code:
Dim span As New TimeSpan(Date.Parse("10:14:29", System.Globalization.CultureInfo.CurrentCulture, Globalization.DateTimeStyles.NoCurrentDateDefault).Ticks)
MsgBox(span.TotalMinutes)
-
Jan 1st, 2004, 01:23 PM
#3
Thread Starter
Fanatic Member
i get an error. i have changed it as u will notice to read the label(lblduration). it comes up with an error.
i am attempting to read the label box value after the timer has been stopped.
Private Sub CmdStopTimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdStopTimer.Click
Timer1.Stop()
Dim span As New TimeSpan(Date.Parse(lblduration.ToString, System.Globalization.CultureInfo.CurrentCulture, Globalization.DateTimeStyles.NoCurrentDateDefault).Ticks)
MsgBox(span.TotalMinutes)
CmdStopTimer.Enabled = False
CmdStartTimer.Enabled = True
End Sub
-
Jan 1st, 2004, 01:28 PM
#4
Shouldn't that be lblduration.Text.ToString? Also you can parse directly to the TimeSpan object but I believe it must have all 3 sections of time (hours:minutes:milliseconds), not for sure though.
VB Code:
Dim span As TimeSpan=TimeSpan.Parse(lblDuration.Text)
Msgbox(span.TotalMinutes)
-
Jan 1st, 2004, 02:09 PM
#5
Frenzied Member
Edneeis is right, although it's overkill to do a ...Text.ToString. Check out what gets returned from:
VB Code:
MsgBox(lblDuration.ToString)
MsgBox(lblDuration.Text)
MsgBox(lblDuration.Text.ToString)
And yeah, you should parse directly to a TimeSpan rather than use the date business - it's way less verbose. That was bad on my part.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|