code_junkie

How do you find Leapyear in VBA?

Nov 11th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public function isLeapYear (yr as integer) as boolean
  2. isLeapYear = false
  3. if (mod(yr,400)) = 0 then isLeapYear = true
  4. elseif (mod(yr,100)) = 0 then isLeapYear = false
  5. elseif (mod(yr,4)) = 0 then isLeapYear = true
  6. end function
  7.  
  8. Public Function isLeapYear(Yr As Integer) As Boolean
  9.  
  10. ' returns FALSE if not Leap Year, TRUE if Leap Year
  11.  
  12. isLeapYear = (Month(DateSerial(Yr, 2, 29)) = 2)
  13.  
  14. End Function
  15.  
  16. public function isLeapYear (yr as integer) as boolean
  17. if (mod(yr,4)) <> 0 then isLeapYear = false
  18. elseif (mod(yr,400)) = 0 then isLeapYear = true
  19. elseif (mod(yr,100)) = 0 then isLeapYear = false
  20. else isLeapYear = true
  21. end function
  22.  
  23. Public Function isLeapYear(Yr As Integer) As Boolean
  24.  
  25. ' returns FALSE if not Leap Year, TRUE if Leap Year
  26.  
  27. isLeapYear = (DAY(DateSerial(Yr, 3, 0)) = 29)
  28.  
  29. End Function
  30.  
  31. Public Function IsLeapYear(Year As Varient) As Boolean
  32. IsLeapYear = IsDate("29-Feb-" & Year)
  33. End Function
Add Comment
Please, Sign In to add comment