Days in Month
-
: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
-
: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
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