Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCalculate the number of days in a month
Keywordsdays, month, calendar
CategoriesUtilities
 
Use CDate to convert the month (e.g. "April, 2000") into a date. The resulting date is the first of the month.

Next use DateAdd to add 1 month, giving the first of the next month. Use DateDiff to find the number of days between these dates.

 
Private Sub cmdGo_Click()
Dim start_of_month As Date
Dim start_of_next_month As Date

    start_of_month = CDate(txtMonth.Text)
    start_of_next_month = DateAdd("m", 1, start_of_month)
    MsgBox "Days: " & Format$(DateDiff("d", start_of_month, _
        start_of_next_month))
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated