0

嘿,我有一首歌正在播放,显示时间如下:

0:00 / 4:47

第一次是曲目当前时间。第二个是该歌曲播放的总曲目时间。

我像这样拆分它:

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

所以tmpTimes(0)给我 0:00 和tmpTimes(1)给我 4:47。

现在我试图从tmpTimes(0)中减去tmpTimes(1 )

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

我得到:447.. 446... 445... 等等

为了返回递减计数,我需要什么样的计算?

示例:4:47...4:46.....4:45...etc使用当前时间tmpTimes(0)

4

2 回答 2

2

You need to split the text MM:SS into Minutes and Seconds, then convert that to total seconds (m * 60 + s). Then you can do the math on seconds. Then you will need to convert it back into Minutes and Seconds for display.

You may also be able to use the Timespan class to do this.

于 2013-01-12T18:14:30.990 回答
0

解决了:

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"))
于 2013-01-14T01:50:03.560 回答