Get the total Days of the Month and Year

By bryan tugade

We can easily get the total days of the mont and year by calling DaysInMonth Function of Date.

Imports System
Partial Class dates_Default
    Inherits System.Web.UI.Page

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        Dim days As Integer = Date.DaysInMonth(youryearhere, yourmonthhere)
        For i As Integer = 1 To days
            DropDownList2.Items.Add(i)
        Next

    End Sub
End Class

Just change the variable passed in DaysInMonth Function.

Related FAQs

I have compiled a different type of format for date and time. Hope this compiled code for date and time can help you.
Get the total Days of the Month and Year  (644 Views)