• HELP!! Leap Year checking(VB.NET)

    Home » Forums » Developers, developers, developers » DevOps Lounge » HELP!! Leap Year checking(VB.NET)

    Author
    Topic
    #411845

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #895846

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

      System.Globalization.Calendar.IsLeapYear()

      • #896247

        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.

      • #896248

        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.

      • #897005

        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.

        • #897068

          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.

          • #897125

            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. clever

            • #897159

              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.

            • #897275

              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. cheers

            • #897276

              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. cheers

            • #897160

              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.

          • #897126

            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. clever

        • #897069

          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.

      • #897006

        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.

    • #895847

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

      System.Globalization.Calendar.IsLeapYear()

    Viewing 1 reply thread
    Reply To: HELP!! Leap Year checking(VB.NET)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: