Get list of dates in a range - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

get list of dates in

For this tutorial we need a LisBox, 2 DateTimePicker and a Button.
When a user select a range of date and click the button, every single date that occurs in that range will be added to the listbox

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
 Handles Button1.Click
        Dim date1 As Date
        Dim date2 As Date

        date1 = DateTimePicker1.Text
        date2 = DateTimePicker2.Text
        If date1 = date2 Then

        ElseIf date1 > date2 Then
            MsgBox("Please Enter a Valid Date Range")

            Do Until date1 = date2
                date1 = date1.AddDays(1)
        End If

    End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.