VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code returns the number of days passed since the given year. The date of year is condsidered f

by Mangesh Gholkar. (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 29th May 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code returns the number of days passed since the given year. The date of year is condsidered from 1st Jan. Currently the starting year

Rate This code returns the number of days passed since the given year. The date of year is condsidered f



On Error GoTo Error
    Dim lngResult As Long
    Dim boolLeap As Boolean
    Dim intMonthCnt As Integer
    
    boolLeap = False
    lngResult = mintDay
    
    Dim lngNumYears As Long
    lngNumYears = mintYear - intFirstYear

    lngResult = lngResult + lngNumYears * 365 + Fix((lngNumYears) / 4)
    
    If mintYear Mod 400 = 0 Or mintYear Mod 4 = 0 Then
        boolLeap = True
    End If
    
    intMonthCnt = 1
    
    While intMonthCnt < mintMonth
        If intMonthCnt = 2 Then
            If boolLeap Then
                lngResult = lngResult + 29
            Else
                lngResult = lngResult + 28
            End If
        ElseIf intMonthCnt < 8 Then
            If intMonthCnt Mod 2 Then
                lngResult = lngResult + 31
            Else
                lngResult = lngResult + 30
            End If
        Else
            If intMonthCnt Mod 2 Then
                lngResult = lngResult + 30
            Else
                lngResult = lngResult + 31
            End If
        End If
        intMonthCnt = intMonthCnt + 1
    Wend
    ReturnNoOfDays = lngResult
    Exit Function

Error:
    MsgBox "Oooooooops, Contact Mangesh at [email protected]", vbCritical, "Count Days...!!!"

End Function


Download this snippet    Add to My Saved Code

This code returns the number of days passed since the given year. The date of year is condsidered f Comments

No comments have been posted about This code returns the number of days passed since the given year. The date of year is condsidered f. Why not be the first to post a comment about This code returns the number of days passed since the given year. The date of year is condsidered f.

Post your comment

Subject:
Message:
0/1000 characters