 | Member with 72 posts. | | | | Check for a leap year in VB A quick way to check if a year is a leap year
public function IsLeap(Year as integer) as boolean
IsLeap = Isdate("29/02/" & Year)
end function | | Distinguished Member with 4,312 posts. | | Join Date: Mar 2000 Location: Central Pennsylvania Experience: Advanced | | Another simple way is divide the year by 4. If it comes out without a remainder it is a leap year. | | Member with 72 posts. | | | | calculating Leap year Its not as simple as just dividing the year by 4, the actual logic for a leap year is:
year is divisible by 4, but NOT by 100 OR year is divisible by 400. | | Distinguished Member with 4,312 posts. | | Join Date: Mar 2000 Location: Central Pennsylvania Experience: Advanced | | Re: calculating Leap year Quote: Originally posted by Aftab: Its not as simple as just dividing the year by 4, the actual logic for a leap year is:
year is divisible by 4, but NOT by 100 OR year is divisible by 400. | DUH I don't see where I said anything about 100 or 400. Could you show where I did ? | | Member with 72 posts. | | | | Calculating Leap Year Quote: |
DUH I don't see where I said anything about 100 or 400. Could you show where I did ?
| You have misunderstood what I said. I was pointing out the actual logic of calculating a leap year, I was not trying to say that you had said anything about dividing by 100 and 400. This is what I was trying to get across: A year is a leap year IF the year is divisible by 4 AND 100, OR is divisible by 400. | | Member with 72 posts. | | | | Leap Year Sorry, slight error in last reply, logic is divisible by 4 but NOT divisible by 100 OR divisible by 400. | | Senior Member with 1,282 posts. | | Join Date: Nov 2003 Location: Oklahoma/Missouri(school) Experience: learning, best with hardware | | why can't it be divisible by 100? | | Distinguished Member with 37,126 posts. | | Join Date: Aug 2003 Location: Corn Fields of OHIO Experience: Einstein Jr. Indeed | |  ALL THIS GAVE ME A HEAD ACHE | | Member with 72 posts. | | | | Leap Years Quote: |
why can't it be divisible by 100?
| The reason it can't be divisible by 100 is because then we would have a leap year every 100 years (century years) as well as every 4 years. This would result in too many extra days being added, about 3 days every 400 years I think. Hope this makes sense. | | Senior Member with 1,282 posts. | | Join Date: Nov 2003 Location: Oklahoma/Missouri(school) Experience: learning, best with hardware |
25-Mar-2004, 08:06 PM
#10 | | | | Distinguished Member with 6,940 posts. | | Join Date: Nov 2003 Location: Kansas Experience: Advanced |
25-Mar-2004, 09:08 PM
#11 | They explained all of that in an article in the Kansas City Star a few weeks ago. Pretty weird stuff it is. | | Senior Member with 1,263 posts. | | Join Date: Mar 2003 Location: 10 mins from Tower of London/England |
25-Mar-2004, 09:23 PM
#12 | | | | Junior Member with 24 posts. | | Join Date: Mar 2004 Location: Planet Earth |
28-Mar-2004, 12:52 AM
#13 | I suppose no one *really* uses the Internet anymore
How about this site: http://www.codetoad.com/vb_leap_year.asp
Any year divisible by 400 will be divisible by 100 as well as 4. The operative function is If divisible by 4 cannot be divisible by 100 - so 2004 is a Leap Year.
2000 is a special case because it was divisble by all three...
( BTW - we do have leap years *every* 100 years | | Junior Member with 24 posts. | | Join Date: Mar 2004 Location: Planet Earth |
28-Mar-2004, 12:58 AM
#14 | Grrr ... I take that last part back - we are entering aperiod where leaps years at the century mark are occuring less often:
$year = 100;
while(1) {
system("cal 2 $year");
sleep 1;
$year+=100;
}
Prior to 1800 every century was a leap year...
Sorry/Bill | | Member with 72 posts. | | |
30-Mar-2004, 03:26 PM
#15 | Leap years Sorry if I didn't make that clear:
A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 08:51 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|