请问VB中的DateDiff函数
DimsqlAsStringDimRecordNumAsLongDimArrayNumAsIntegerDimfor_numAsIntegerDimSheetNoAsIn...
Dim sql As String
Dim RecordNum As Long
Dim ArrayNum As Integer
Dim for_num As Integer
Dim SheetNo As Integer
Dim TimeStart As Date
Dim TimeDiffLong As Long
Dim TimeDiffStr As String
Dim RecordVelocity As Long
Dim TimeLeftSecond As Long
Dim TimeLeft As String
Do While Not RS.EOF
TimeStart = Time()
'**************************************
……’从数据库中取数
'**************************************
TimeDiffLong = DateDiff("s", TimeStart, Time)
TimeDiffStr = CStr(TimeDiffLong \ 3600) & "小时" & CStr(TimeDiffLong \ 60) & "分" & CStr(TimeDiffLong Mod 60) & "秒"
RecordVelocity = RecordNum / TimeDiffLong
TimeLeftSecond = (RecordSum - RecordNum) / RecordVelocity
TimeLeft = CStr(TimeLeftSecond \ 3600) & "小时" & CStr(TimeLeftSecond \ 60) & "分" & CStr(TimeLeftSecond Mod 60) & "秒"
Application.StatusBar = "共有记录数" & RecordSum & "条,预计占用" & SheetSum & "个Sheet页。目前位于Sheet" & SheetNo & ",第" & RecordNum & "行。已耗时" & TimeDiffStr & ",预计剩余时间" & TimeLeft
RS.MoveNext
Loop '循环
RS.Close
执行完后
TimeDiffLong = DateDiff("s", TimeStart, Time)的结果为零。请问为什么?(通过设置断点进行调试得知TimeStart与Time的值是不同的)
奇怪!两个显示的都是17:27:51。但是在中断调试里面看两个值是不一样的(但差值还是零)。但是还有一个问题,当处于断点的时间足够长时,差值就不再是零了。但是这个足够长的时间是多少?我现在还在知道。 展开
Dim RecordNum As Long
Dim ArrayNum As Integer
Dim for_num As Integer
Dim SheetNo As Integer
Dim TimeStart As Date
Dim TimeDiffLong As Long
Dim TimeDiffStr As String
Dim RecordVelocity As Long
Dim TimeLeftSecond As Long
Dim TimeLeft As String
Do While Not RS.EOF
TimeStart = Time()
'**************************************
……’从数据库中取数
'**************************************
TimeDiffLong = DateDiff("s", TimeStart, Time)
TimeDiffStr = CStr(TimeDiffLong \ 3600) & "小时" & CStr(TimeDiffLong \ 60) & "分" & CStr(TimeDiffLong Mod 60) & "秒"
RecordVelocity = RecordNum / TimeDiffLong
TimeLeftSecond = (RecordSum - RecordNum) / RecordVelocity
TimeLeft = CStr(TimeLeftSecond \ 3600) & "小时" & CStr(TimeLeftSecond \ 60) & "分" & CStr(TimeLeftSecond Mod 60) & "秒"
Application.StatusBar = "共有记录数" & RecordSum & "条,预计占用" & SheetSum & "个Sheet页。目前位于Sheet" & SheetNo & ",第" & RecordNum & "行。已耗时" & TimeDiffStr & ",预计剩余时间" & TimeLeft
RS.MoveNext
Loop '循环
RS.Close
执行完后
TimeDiffLong = DateDiff("s", TimeStart, Time)的结果为零。请问为什么?(通过设置断点进行调试得知TimeStart与Time的值是不同的)
奇怪!两个显示的都是17:27:51。但是在中断调试里面看两个值是不一样的(但差值还是零)。但是还有一个问题,当处于断点的时间足够长时,差值就不再是零了。但是这个足够长的时间是多少?我现在还在知道。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询