Windows2012发布后,未来也许就是通过Shell去管理Windows了,因此最近着迷windows shell和power shell,coding来自《Windows脚本编程核心技术精解》
yourself = "What's your birthday"
yourage = "Let's see how old you are"
do
birthday = InputBox(yourself,yourage)
'check whether the user wants to quit:
if isEmpty(birthday) then
MsgBox "Hey! you could always lie to me to hide" & "your age! but ok. i quit!"
WScript.Quit
elseif not isDate(birthday) then
'check whether birther is ceally a date
'complain and give another chance:
MsgBox "You didn't enter a valid date! Try again"
end if
'loop untile a valid date was retrieved
loop until isDate(birthday)
age_in_days = DateDiff("d",birthday,date)
age_in_months = DateDiff("m",birthday,date)
age_in_years = DateDiff("yyyy",birthday,date)
day_born = WeekdayName(Weekday(birthday))
date_day = Day(birthday)
date_month = Month(birthday)
date_year = Year(date)
this_years_birthday = DateSerial(date_year,date_month,date_day)
days_to_birthday = Abs(DateDiff("d",date,this_years_birthday))
day_celebrating = WeekdayName(Weekday(this_years_birthday))
if this_years_birthday < date then
message = "you celebrated your birthday" & days_to_birthday & " days ago"
elseif this_years_birthday = date then
message = "Hayyp Birthday!!!"
else
message = days_to_birthday & "days to go !"
end if
msg = "This is your birthday analysis:" & vbCr
MsgBox (msg)
msg = msg + "You are born on " & birthday & vbCr
MsgBox (msg)
msg = msg + "You are " & age_in_years & " yrs old. that's " & vbCr
MsgBox (msg)
msg = msg & age_in_months & "months or " & age_in_days & " days! " &vbCr
MsgBox (msg)
msg = msg + " You were born on a " & day_born & cbCr
MsgBox (msg)