Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Days in Month

Days in Month

Scheduled Pinned Locked Moved Visual Basic
helpcsharplearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cedrickdeorange
    wrote on last edited by
    #1

    :sigh: To begin, I have just started a VB.Net course. I am an absolute begginer, so be gentle with me. I have a problem with getting the correct amount of days in the right month. I have been at this all day and i'm still stuck. Any ideas would be most helpful Regards Cedrick de'Orange

    J 1 Reply Last reply
    0
    • C Cedrickdeorange

      :sigh: To begin, I have just started a VB.Net course. I am an absolute begginer, so be gentle with me. I have a problem with getting the correct amount of days in the right month. I have been at this all day and i'm still stuck. Any ideas would be most helpful Regards Cedrick de'Orange

      J Offline
      J Offline
      jsampsonPC
      wrote on last edited by
      #2

      You'll find your answer in the Date object. There is a public method called DaysInMonth which takes two arguments, the Year, and the Month - both integers. Label1.Text = Date.DaysInMonth(year As Integer, month As Integer) Label1.Text = Date.DaysInMonth(2006, 7) "I forgot to add, I am using a domain up and down for the months and a numeric up and down for the days" What do you mean 'domain up and down'. As for the Numeric up and down controller, just use the .Value property of the NumericUpDown control. You will also have to cast the value to an Integer, because the DaysInMonth method will not accept a Decimal value, which is what NumericUpDown naturally is. Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged Label1.Text = Date.DaysInMonth(2006, CInt(NumericUpDown1.Value)) End Sub

      Jonathan Sampson www.SampsonResume.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups