Click here to Skip to main content
14,927,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i need display how many days in a month if i am enter the year and month in textbox and display the days in next box using vb.net in windows application

please help me
Posted
Updated 18-Feb-20 23:13pm

1 solution

You could try the DateTime.DaysInMonth Method[^]
   
Comments
Member 8614787 22-Mar-12 5:02am
   
Hi I used this code but i got error Following error (Month must be between one and twelve.Parameter name: month) this is my code

Dim year As Integer
Dim month As Integer
Dim days As Integer = System.DateTime.DaysInMonth(year, month) //(Month must be between one and twelve.Parameter name: month)
TextBox7.Text = days
OriginalGriff 22-Mar-12 5:08am
   
You could try giving it an actual year and month...

Dim year As Integer = 2012
Dim month As Integer = 2
Dim days As Integer = System.DateTime.DaysInMonth(year, month)
Member 8614787 22-Mar-12 5:15am
   
hi,

ya this above code is working correct, but my requirments is enter the value in runtime only inside textbox i give input is 2012,4 means display the no of days in next textbox(30) i think clear my requirments..
OriginalGriff 22-Mar-12 5:23am
   
So read the value from the TextBox, use string.Split to break it on the comma, then convert the two numbers to integers with Parse or TryParse.
Member 8614787 22-Mar-12 5:26am
   
can you give code to me i am not idea about this one anyway i get the output is no of days in the month can you help me
OriginalGriff 22-Mar-12 5:31am
   
Dim parts As String() = tbYearAndMonthEntered.Text.Split(","C)
Dim year As Integer
Dim month As Integer
If parts.Length = 2 Then
year = Integer.Parse(parts(0))
month = Integer.Parse(parts(1))
...
End If
Member 8614787 22-Mar-12 6:03am
   
Thanks for your code it's working now thanks for spend your time to me,,

Thanks,
OriginalGriff 22-Mar-12 6:30am
   
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900