Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey all i have a song playing that displays the time like so:

 

0:00 / 4:47

 

The first time is the tracks current time. The second is the total track time of that song playing.

 

I split it like so:

Dim tmpTimes As Array = lblSongTime.Text.Split("/")

 

So tmpTimes(0) gives me 0:00 and tmpTimes(1) gives me 4:47.

 

Now i tried to subtract the tmpTimes(1) from tmpTimes(0)

Debug.Print(CDbl(tmpTimes(1).replace(":", "") - tmpTimes(0).replace(":", "")))

and i get: 447.. 446... 445... etc

 

What kind of calculation do i need in order to return a descending count?

 

Example: 4:47...4:46.....4:45...etc using the current time tmpTimes(0)?

Posted

Solved:

 

Dim times As String() = lblSongTime.Text.Split("/"c)
Dim elapsedTime As TimeSpan = TimeSpan.ParseExact(times(0).Trim(), "m\:ss", Nothing)
Dim totalTime As TimeSpan = TimeSpan.ParseExact(times(1).Trim(), "m\:ss", Nothing)
Dim remainingTime As TimeSpan = totalTime - elapsedTime

Debug.WriteLine(remainingTime.ToString("m\:ss"))

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...