Link to home
Start Free TrialLog in
Avatar of Sharalynn
SharalynnFlag for United States of America

asked on

Calculation for leap year?

I am currently trying to calculate if a year is a leap year or not. arrYear(i) would be just a input for the year..

So, I entered the year 2008 and it return a false. What gives?
Dim blnLeapYear As Boolean = ((arrYear(i) Mod 4 = 0) And (arrYear(i) Mod 100 = 0)) Or (arrYear(i) Mod 400 = 0)

Open in new window

SOLUTION
Avatar of Oliver Amaya
Oliver Amaya
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sharalynn

ASKER

Thank you both so much!

For some reason the built-in function returns an error:
Year must be between 1 and 9999.
Parameter name: year

However the 2nd one works great. I must have done the 1st one wrong somehow. Just fyi, I get the value from a dropdownlist using something like ddlYear1.SelectedItem.Value
Nice!
Well as the error says you're sending a number that is either lower than 1 or higher than 9999, maybe you got a null or empty value in your DropDownList?, it's always good to add validations so that exceptions like that are not raised.
That's weird because after the value has been retrieved, the 2nd one work for me but the first one didn't. I also made sure the value has been converted of type Integer first. There are only 3 year values as well. No idea what happened there. Ah well, it works out in the end anyway. Choices are good!