想请教如何加减时间的小时与分钟

  • Thread starter Thread starter christing
  • Start date Start date
C

christing

Guest
我篇写了有关计算小时与分钟的代码我下请教可以如何准确的加减到小时与分钟以下是我的代码?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim TimeIn As String
Dim TimeOut As String
Dim Result As String

TimeIn = txt1.Text
TimeOut = txt2.Text

Result = CStr(CDbl(TimeOut) - CDbl(TimeIn))
txtReult.Text = Result

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Result As String = txtReult.Text
Dim Result1 As String
Dim Equal As String = "9.35"

Try
Result1 = CStr(CDbl(Result) - CDbl(Equal))
txtEqual.Text = Result1
Catch ex As Exception
MessageBox.Show("You select wrong part")
End Try

End Sub


user time in 时间如果是7.30 到 5.05 的话 无法计算到一天工作是9小时35分钟

Continue reading...
 
Back
Top