do
dim KSwith,SomeDate,NDays
do
KSwith=inputbox("计算某天距今的天数请输入数字1;"&chr(10)&"获取N天前或N天后的日期请输入数字2。"&chr(10)&"(不输入任何东西点击任一按钮则退出)")
if KSwith="1" or KSwith="2" or KSwith="" then
exit do
end if
loop
if KSwith="1" then
do
SomeDate=inputbox("请输入日期"&chr(10)&"(日期范围公元100年1月1日至9999年12月31日,日期格式参照 2012-1-1)。"&chr(10)&"(不输入任何东西点击任一按钮则退出)")
if isdate(SomeDate)=true or SomeDate="" then
exit do
end if
loop
if SomeDate="" then '输入日期处如果不输入任何东西,点击任一按钮即退出
exit do
else
msgbox("距今")&abs(datediff("d",date,cdate(SomeDate)))&"天"
end if
else
if KSwith="2" then
do
NDays=inputbox("你想得到多少天后/前的日期?(N天后键入正数,N天前键入负数)。"&chr(10)&"(不输入任何东西点击任一按钮则退出)")
if isnumeric(NDays)=true or NDays=""then
exit do
end if
loop
if NDays="" then
exit do
else
msgbox("获得日期为:"&chr(10))&dateadd("d",NDays,date)
end if
else
exit do
end if
end if
loop