0

我得到了这个字符串:

00:00:59,950


假设我想要:
00:00:59,950 + 100

那么字符串看起来像:
00:01:00,050
有一个函数可以做到吗?

4

2 回答 2

2

您可以使用TimeSpan类型来处理此问题:

Dim ci = CultureInfo.InvariantCulture
Dim original As TimeSpan = TimeSpan.ParseExact("00:00:59,950", "hh\:mm\:ss\,fff", ci)
Dim difference As TimeSpan = TimeSpan.FromMilliseconds(100)

Dim final = original + difference

Dim output as String = final.ToString("hh\:mm\:ss\,fff", ci)
于 2012-06-12T17:54:47.130 回答
0

尝试这个:

    Dim dateFormat As String = "hh:mm:ss.fffffff" 
    Dim date1 As Date = #00:00:59,950"
    date1.AddMilliseconds(100)

更新:

我一定比昨天意识到的更累,对此我深表歉意。这应该做得更好:

    Dim sTime As String = "00:00:59.950"
    Dim dOffset As DateTimeOffset = DateTimeOffset.Parse(sTime)
    dOffset = dOffset.AddMilliseconds(100)

    Dim sDisplayTime As String = dOffset.ToString("HH:mm:ss.fff tt")

在那里,您将以您在问题中所述的格式获得毫秒数。

于 2012-06-12T17:55:07.680 回答