VB 时间间隔如何写?
来源:百度知道 编辑:UC知道 时间:2024/05/16 02:31:49
从14:00开始计,到第二天的16:00为一天,如果我当天12:00分开始借书,到第二天的16:00应为两天计算。如何编写?
日期时间tb 借 tr 还
function getdays(byval tb as date ,byval tr as date ) as integer
dim d as integer
d=0
if fromat (ts,"HH:mm") < "14:00") then
d=d+1
endif
if fromat (tr,"HH:mm") > "16:00") then
d=d+1
endif
d=d+datediff("d",ts,tr)
getdays=d
end function
这个问题你完全可以写一个计算时间的程序!
没看明白什么意思。。
感觉逻辑上有问题,试想一下连着借多天时的情况,从14:00到当天的16:00这段时间怎么算?
我添加了2个 DTpicker 控件 具体代码如下:
Private Sub Command1_Click()
Dim hTemp As Integer '总小时数
Dim iDay As Integer '需要的天数 (你是26小时算一天)
Dim iGao As Integer
hTemp = (DTPicker2.Value - DTPicker1.Value) * 24 + (Combo2.ListIndex - Combo1.L