Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This Function Returns number of days in a month of...
Author:
Aswarthraj
E-mail:
Click to e-mail author
Submitted:
7/17/2002
Version:
VB5
Compatibility:
VB5, VB6
Category:
Date/Time
Views:
14880
This Function Returns number of days in a month of any calender month. For Example In leap year 2000 number of days in February is 29. To know this we have to write alot of code with if and case statements. Instead of the above long code you can add the following function to your project and reduce the code length.
Declarations:
'none
Code:
Private Sub Form_Activate() MsgBox GetDaysInMonth("01/02/2000") End Sub Public Function GetDaysInMonth(lMonth As String) As Integer If IsDate(lMonth) = True Then lMonth = Format(lMonth, "dd/MM/yyyy") GetDaysInMonth = DateDiff("D", lMonth, DateAdd("M", 1, lMonth)) Else MsgBox "Date is not Correct! Date should be in 'dd/MM/yyyy' or 'dd/MM/yy' Format.", vbInformation GetDaysInMonth = 0 End If End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement