回 帖 发 新 帖 刷新版面

主题:时间判断出现问题了,来帮帮忙。

下面是我做的一个时间判断程序,但是总是出错当now_time_hour的初始值等于0-8时,没有问题,但是当now_time_hour的初始值等于其他值时,程序会自动的判断为第二个选项,同时把now_time_hour设为08,这是怎么回事呢,大家帮我看看。谢谢了








    Set regEx = New RegExp            regEx.Pattern = "(\d{4})-(\d{1,2})-(\d{1,2}).(\d{1,2}):(\d{1,2})"    regEx.IgnoreCase = True    
    regEx.Global = True    
    Set Matches = regEx.Execute(now)    
    For Each Match in Matches 
    now_time_year=Match.submatches(0)
    now_time_month=Match.submatches(1)
    now_time_day=CLng(Match.submatches(2))
    now_time_hour=CLng(Match.submatches(3))
    now_time_minute=CLng(Match.submatches(4))
    Next
set regEx=nothing
now_time_date=date
if now_time_hour<08 or (now_time_hour=08 and now_time_minute<30) then  '8:30以前
now_time_hour=20
elseif 08<now_time_hour<12 or (now_time_hour=08 and now_time_minute>=30) or (now_time_hour=12 and now_time_minute<30) then  '8:30到12:30
now_time_hour=08
elseif 12<now_time_hour<20 or (now_time_hour=12 and now_time_minute>=30) or (now_time_hour=20 and now_time_minute<30) then'12:30到20:30
now_time_hour=12
elseif 20<now_time_hour or (now_time_hour=20 and now_time_minute>=30) then'20:30以后
now_time_hour=20
now_time_date=dateadd("d",1,date)
end if
update_date=cdate(now_time_year&"-"&now_time_month&"-"&now_time_day&" "&now_time_hour&":00:00")

回复列表 (共1个回复)

沙发

问题已经解决了,不能这样写:elseif 08<now_time_hour<12 
改成elseif now_time_hour>8 and now_time_hour<12 就好了

我来回复

您尚未登录,请登录后再回复。点此登录或注册