Imports Microsoft.VisualBasic
Imports System.Data
Public Class DropDownList
Public Shared Function MonthReturnDay(ByVal Year As String,ByVal Month As String,ByVal DropDownListDay As System.Web.UI.WebControls.DropDownList) As Integer
Dim day,i As Integer
Dim isleap As Boolean
If Len(Month.Trim) = 1 Then
Month = "0" & Month
End If
Select Case Month.Trim
Case "01"
day = 31
Case "02"
isleap = False
If Val(Right(Year,4)) Mod 100 = 0 Then
If Val(Right(Year,4)) Mod 400 = 0 Then
isleap = True
End If
Else
If Val(Right(Year,4)) Mod 4 = 0 Then
isleap = True
End If
End If
If isleap = True Then
day = 29
Else
day = 28
End If
Case "03"
day = 31
Case "04"
day = 30
Case "05"
day = 31
Case "06"
day = 30
Case "07"
day = 31
Case "08"
day = 31
Case "09"
day = 30
Case "10"
day = 31
Case "11"
day = 30
Case "12"
day = 31
End Select
Dim k As String
DropDownListDay.Items.Clear()
DropDownListDay.Items.Add("")
For i = 1 To day
If i < 10 Then
k = "0" & i
Else
k = i
End If
DropDownListDay.Items.Add(k)
Next
End Function
End Class
原文链接:https://www.f2er.com/vb/262370.html