在线等待回复,谢谢

解决方案 »

  1.   

    好像沒有,以下是我自已寫的Public Function MaxDay(Year As Integer, Month As Integer) As Integer
        
        If Month > 0 And Month < 13 Then
            If IsDate(Year & "/" & Month & "/" & 31) Then
                MaxDay = 31
            ElseIf IsDate(Year & "/" & Month & "/" & 30) Then
                MaxDay = 30
            ElseIf IsDate(Year & "/" & Month & "/" & 29) Then
                MaxDay = 29
            Else
                MaxDay = 28
            End If
        Else
            MaxDay = 0
        End If
        
    End FunctionPublic Function LastDay(ByVal Year As Integer, ByVal Month As Integer) As Date
        
        If Month > 0 And Month < 13 Then
            If IsDate(Year & "/" & Month & "/" & 31) Then
                LastDay = DateSerial(Year, Month, 31)
            ElseIf IsDate(Year & "/" & Month & "/" & 30) Then
                LastDay = DateSerial(Year, Month, 30)
            ElseIf IsDate(Year & "/" & Month & "/" & 29) Then
                LastDay = DateSerial(Year, Month, 29)
            Else
                LastDay = DateSerial(Year, Month, 28)
            End If
        Else
            LastDay = 0
        End If
        
    End Function
      

  2.   

    Day(CDate(Trim(Str((Year(Now)))) & "-" & Trim(Str(Month(Now) + 1)) & "-1") - 1)
      

  3.   

    下列函数计算 mydate 所在的月份的天数:
    Public Function Month_Days(ByVal mydate As Date) As Integer
    Dim startday, endday As Date
    startday = Format(mydate, "yyyy-mm-01")
    endday = DateAdd("m", 1, startday)
    Month_Days = DateDiff("d", startday, endday)
    End Function
      

  4.   

    Day(CDate(Trim(Str((Year(Now)))) & "-" & Trim(Str(Month(Now) + 1)) & "-1") - 1)
    这个代码明显有问题嘛,楼主竟然给了30分。你看看十二月份的日期加一都成了13月了!