Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated