Vb.net两次togeather HH:从MM到文本框

时间:2014-07-25 01:00:35

标签: vb.net

所以我有2个标签,时间变化我需要将它们加在一起它们不会保持不变但我找不到让它们添加正确的方法。这就是我所拥有的。

    Dim Time1, Time2 As String
    Dim TotalTime As Integer

    'The Time that is in Lable is in Hours and Mins.
    'Example 0:13 is 13 Mins
    'Example 1:45 is 1 Hour and 45 mins 
    Time1 = Convert.ToInt32(lblTime1)
    Time2 = Convert.ToInt32(lblTime2)

    TotalTime = Time1 + Time2
End Sub

1 个答案:

答案 0 :(得分:1)

从标签“Text s:

中解析TimeSpan
Dim time1 = TimeSpan.ParseExact(lblTime1.Text, "h\:mm", CultureInfo.CurrentCulture)
Dim time2 = TimeSpan.ParseExact(lblTime2.Text, "h\:mm", CultureInfo.CurrentCulture)

Dim totalTime = time1 + time2