tags:

views:

178

answers:

4

hi guys, i have a textbox that displays date in format,for eg:March,20,2008.Then i need to get total days n march in year 2008.Can anybody help

+3  A: 
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int numDays = DateTime.DaysInMonth(year, month);
Rashack
beat by 2 seconds!
John Nolan
+5  A: 

You can use the DaysInMonth function

e.g.

Date.DaysInMonth(2008, 3)

Obviously, you'll have to pass the year and month to the function

kevchadders
A: 

Remember to use the date they entered. VB Code:

dim enteredDate as DateTime = cdate(txtDateBox.text)
dim daysInMonth as Int = DateTime.DaysInMonth(enteredDate.year,enteredDate.month)
Damien