告诉你两种判断闰年的简单方法
2006-02-27 11:51:55 来源:WEB开发网核心提示:OptionExplicitPRivateSubCommand1_Click()Print2000PrintIsLeapYearA(2000)PrintIsLeapYearB(2000)Print1999PrintIsLeapYearA(1999)PrintIsLeapYearB(1999)Print1998Print
OptionExplicit
PRivateSubCommand1_Click()
Print2000
PrintIsLeapYearA(2000)
PrintIsLeapYearB(2000)
Print1999
PrintIsLeapYearA(1999)
PrintIsLeapYearB(1999)
Print1998
PrintIsLeapYearA(1998)
PrintIsLeapYearB(1998)
Print1997
PrintIsLeapYearA(1997)
PrintIsLeapYearB(1997)
Print1996
PrintIsLeapYearA(1996)
PrintIsLeapYearB(1996)
EndSub
FunctionIsLeapYearA(ByValyrAsInteger)AsBoolean
If((yrMod4)=0)ThenIsLeapYearA=((yrMod100)>0)Or((yrMod400)=0)
EndIf
EndFunction
PublicFunctionIsLeapYearB(ByValyrAsInteger)AsBoolean
IsLeapYearB=Day(DateSerial(yr,2,29))=29
EndFunction->
PRivateSubCommand1_Click()
Print2000
PrintIsLeapYearA(2000)
PrintIsLeapYearB(2000)
Print1999
PrintIsLeapYearA(1999)
PrintIsLeapYearB(1999)
Print1998
PrintIsLeapYearA(1998)
PrintIsLeapYearB(1998)
Print1997
PrintIsLeapYearA(1997)
PrintIsLeapYearB(1997)
Print1996
PrintIsLeapYearA(1996)
PrintIsLeapYearB(1996)
EndSub
FunctionIsLeapYearA(ByValyrAsInteger)AsBoolean
If((yrMod4)=0)ThenIsLeapYearA=((yrMod100)>0)Or((yrMod400)=0)
EndIf
EndFunction
PublicFunctionIsLeapYearB(ByValyrAsInteger)AsBoolean
IsLeapYearB=Day(DateSerial(yr,2,29))=29
EndFunction->
更多精彩
赞助商链接