by Ijagbemi Bayode (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 14th January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
To get the total number of days in a month and detect Leap year
API Declarations
dim GetDate as date
Function GetValues(ByVal MyFirstDate As Date) As Integer
Dim Getmonth, workDay, Curyear
Curyear = Year(MyFirstDate)
Getmonth = Month(MyFirstDate)
Select Case Getmonth
Case 1
workDay = 31
Case 2
If LeapYear(Curyear) = True Then
workDay = 29
Else
workDay = 28
End If
Case 3
workDay = 31
Case 4
workDay = 30
Case 5
workDay = 31
Case 6
workDay = 30
Case 7
workDay = 31
Case 8
workDay = 31
Case 9
workDay = 30
Case 10
workDay = 31
Case 11
workDay = 30
Case 12
workDay = 31
Case Else
workDay = 0
MsgBox "Invalid Number of days", vbCritical,
End Select
GetValues = workDay
End Function
' Function Gets The Leap Year
Function LeapYear(ByVal TheYear As Integer) As Boolean
LeapYear = ((TheYear Mod 4 = 0 And (TheYear Mod 100 <> 0 Or (TheYear Mod 400 = 0))))
End Function
No comments have been posted about To get the total number of days in a month and detect Leap year. Why not be the first to post a comment about To get the total number of days in a month and detect Leap year.