在给我不好的反馈之前,请先帮助我。
我需要在文本框中添加两次。但是,当我添加时,只有分钟在添加,而不是小时。
Dim dt As DateTime = TxtDTEAP.Text
Dim wt As DateTime = TxtWTEAP.Text
Dim totalspan As New TimeSpan
Dim result As New DateTime
result = dt.AddMinutes(wt.Minute)
Me.TxtTRTEAP.Text = result
例如,txtWTEAP.Text = 1:30
和txtDTEAP.Text = 2:50
的结果应为4:20
,但此代码上显示的结果仅为1:20
。
非常感谢您!
答案 0 :(得分:0)
Private Sub GetTotalTime()
Dim parseTime1() As String = TxtDTEAP.Text.Split(":"c)
Dim parseTime2() As String = TxtWTEAP.Text.Split(":"c)
Dim dt As TimeSpan = New TimeSpan(CInt(parseTime1(0)), CInt(parseTime1(1)), 0)
Dim wt As TimeSpan = New TimeSpan(CInt(parseTime2(0)), CInt(parseTime2(1)), 0)
Dim result As TimeSpan = dt + wt
TxtTRTEAP.Text = result.ToString("h\:mm")
End Sub