循环问题~~~~~求助~~~~~~
原文:
dim LastTime,UStatus,ttt,hours,ii,tt,cc,tes
LastTime=rs1( "LastLoginTime ")
ttt=now()
UStatus=DateDiff( "n ",LastTime,ttt)
If UStatus <=10 then
Response.Write "当前在线 "
tes= "小时内登陆过 "
else If UStatus> 10 and UStatus <=60 then hours=1
else If UStatus> 60 and UStatus <=120 then hours=2
else If UStatus> 120 and UStatus <=180 then hours=3
else If UStatus> 180 and UStatus <=240 then hours=4
else If UStatus> 240 and UStatus <=300 then hours=5
end if
end if
end if
end if
end if
end if
Response.Write hours&tes
我想把
else If UStatus> X and UStatus <=X then hours=X
和
end if
循环24次~~~~不然要写很多代码~~~
下面是我写的循环代码~~~语法不对~~提示缺少loop~~~~大家帮忙看看该怎么写?
dim LastTime,UStatus,ttt,hours,ii,tt,cc,tes
LastTime=rs1( "LastLoginTime ")
ttt=now()
UStatus=DateDiff( "n ",LastTime,ttt)
If UStatus <=10 then
Response.Write "当前在线 "
else
tes= "小时内登陆过 "
ii=0
tt=0
do
ii=ii+60
tt=tt+1
else If UStatus> ii and UStatus <=ii+60 then hours=tt
if ii=1440 and tt=24 then exit do
loop
tt=0
do
tt=tt+1
end if
if tt=24 then exit do
loop
end if
Response.Write hours&tes
------解决方案--------------------明确循环次数的为什么不用For...Next循环?
------解决方案--------------------一次循环也不用,
UStatus=DateDiff( "n ",LastTime,ttt)
if UStatus < 10 then
Response.Write "当前在线 "
else
hours=(UStatus + 59) / 60 '注意,是整除/ 不是\
end if
------解决方案--------------------lz要学学算法啊