以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 时间判断问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188681) |
-- 作者:xxfoxtable -- 发布时间:2023/10/11 6:52:00 -- 时间判断问题 7:00-12:00每小时10元,12:01-18:00每小时15,18:01-00:00每小时20 如果从早上8点到晚上19点,怎么断,消费了多少钱?
|
-- 作者:有点蓝 -- 发布时间:2023/10/11 8:38:00 -- Dim d1 As Date = #10/10/2023 08:00# Dim d2 As Date = #10/10/2023 19:00# Dim sum As Double = 0 Do While d1 <= d2 If d1.Hour >= 7 AndAlso d1.Hour <= 12 Then sum += 10 ElseIf d1.Hour > 12 AndAlso d1.Hour <= 18 Then sum += 15 ElseIf d1.Hour > 18 AndAlso d1.Hour <= 23 Then sum += 20 End If d1 = d1.AddHours(1) Loop MsgBox(sum)
|