VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Use this code to work out the Dates between two givern Dates. Currently it works by taking a value

by Anaru Hartley (3 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 4th December 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Use this code to work out the Dates between two givern Dates. Currently it works by taking a value such as "7" and then it will work out every

API Declarations


* Add The Code to your Form Load Procedure.

Option Explicit

Dim Day as Integer
Dim Month as Intger
Dim Year as Integer

Dim LoopDays As Integer
Dim LoopCount As Integer
Dim LoopTimes As Integer

Rate Use this code to work out the Dates between two givern Dates. Currently it works by taking a value



LoopCount = 0

'Set Todays Date as Start Point.
'This can easily be modified by capable progammers.
'Always pass in the Date as a whole digit (ie. 1,1,2004 not 01,01,2004)

Day = Format(Date,"D")
Month = Format(Date,"M")
Year = Format(Date,"YYYY")

'Define How many Days in the Defined Month

Select Case Month
    Case 1
    LoopDays = 31
    Case 2
    LoopDays = 29
    Case 3
    LoopDays = 31
    Case 4
    LoopDays = 30
    Case 5
    LoopDays = 31
    Case 6
    LoopDays = 30
    Case 7
    LoopDays = 31
    Case 8
    LoopDays = 31
    Case 9
    LoopDays = 30
    Case 10
    LoopDays = 31
    Case 11
    LoopDays = 30
    Case 12
    LoopDays = 31
End Select

Do Until LoopCount = LoopTimes

    List.AddItem Day & "/" & Month & "/" & Year

    If Day = 1 Tehn
        Day = LoopDays
        Month = Month - 1
        Select Case Month
            Case 1
            LoopDays = 31
            Case 2
            LoopDays = 29
            Case 3
            LoopDays = 31
            Case 4
            LoopDays = 30
            Case 5
            LoopDays = 31
            Case 6
            LoopDays = 30
            Case 7
            LoopDays = 31
            Case 8
            LoopDays = 31
            Case 9
            LoopDays = 30
            Case 10
            LoopDays = 31
            Case 11
            LoopDays = 30
            Case 12
            LoopDays = 31
        End Select
    Else
        Day = Day - 1
    End If

    LoopCount = LoopCount + 1

Loop

Download this snippet    Add to My Saved Code

Use this code to work out the Dates between two givern Dates. Currently it works by taking a value Comments

No comments have been posted about Use this code to work out the Dates between two givern Dates. Currently it works by taking a value . Why not be the first to post a comment about Use this code to work out the Dates between two givern Dates. Currently it works by taking a value .

Post your comment

Subject:
Message:
0/1000 characters