在.net中,因为calendar没有JAVA中那么好使用,或者说我不会使用。。。

那么就用土方法来获得每个月的最大天数

 

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Me.TextBox2.Text = getLastDay("2000", Me.TextBox1.Text).ToString()


End Sub

Public Function getLastDay(ByVal year As String, ByVal month As String) As Integer
Dim day As Integer = 0
Select Case month
Case "01", "03", "05", "07", "08", "10", "12"
day = 31
Case "04", "06", "09", "11"
day = 30
Case "02"
If Not year Mod 4 <> 0 Or year Mod 100 = 0 And year Mod 400 = 0 Then
day = 28
Else
day = 29
End If
Case Else
day = 30
End Select

Return day
End Function
End Class