Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HELP!! Leap Year checking(VB.NET)

    Trying to figure out the VB.NET code to check whether or not a year is a leap year. I need the year to be entered in an input box, then the check on the whether the year is a leap year done. I need a "yes" or "no" answer displayed in a textbox. Attached is what the form would look like. Or here is more what I am doing.

    The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was declared a lear year, with the exception of the years ending in 00 (that is, those divisible by 100) and not divisible by 400. For instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Now I am trying to write a program that requests a year as input and states whether it is a leap year.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    Hi Brandon,
    You'll love this... There's already an IsLeapYear() function built in to the .NET Framework:

    System.Globalization.Calendar.IsLeapYear()

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    Ayup, .NET has everything but the kitchen sink.

    They even fixed the ..., oops, if I mentioned it, then I'd get into a discussion, no time for that!

    One can only hope that Office 12 (apparantly scheduled for 2006) will be fully .NET-ized so we can take advantage of the goodies.

  4. #4
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    Ah but I wasn't allowed to use the IsLeapYear check. Had to do it the old fasion way. I remembered how to after a little while. Just a simple if then statement.

    If ((year Mod 4 = 0) And (year Mod 100 <> 0) Or (year Mod 400 = 0)) Then

    So it all worked out. Thanks for the input.

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    Why could you not not use IsLeapYear?

    I was able to run the V Bexample given in the Help.
    I created a Console Application and plopped the code into the critter.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: HELP!! Leap Year checking(VB.NET)

    Possibly it was a school assignment, Howard? Students aren't always allowed to do it the easy way before they understand how to do it the hard way. <img src=/S/clever.gif border=0 alt=clever width=15 height=15>
    Charlotte

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    Heck, we are ALL students.
    I learn something EVERY day, tho, as I get older, I may forget more than I learn.

    For a beginner. even finding the IsLeapYear function would be a challenge, and figuring out how to apply the given example in Help, may be beyond most beginners.

  8. #8
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: HELP!! Leap Year checking(VB.NET)

    An assignment of sorts yes. For me not as much as the kids in my class. I had forgoten all about using MOD for some reason or another at first until I went back through old work where I needed to know that and before the IsLeapYear was available to use. I must say that .NET is one of the greatest things though. And Howard is quite right. We are all always students in the world of programming. Can't know it all though there are people out there that know so much it seems you'll never catch them, but those are our programming vets who have been doing it for so long that is is almost second nature. I can say those guys have helped me out more than I could ever hope. Thanks for the help though guys. If it weren't for all of you we could all be lost. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •