各位大哥~~怎么初始化本月的天数~~请指教~~~
下面这个语句对吗?
dateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)))
        txtItem(0) = Day(dateTemp)
注~~CInt(cboYear),CInt(cboMonth)分别为年,月的组合框

解决方案 »

  1.   

    a = DateAdd("m", 1, DateSerial(CInt(cboYear), CInt(cboMonth), 1)) '下一个月一号
    b =datediff("d",DateSerial(CInt(cboYear), CInt(cboMonth), 1),a) 
      

  2.   


    '---------------------------------------------------------------------------------------
    ' 程式名    : f_MonthDays
    ' 目的      : 計算某年某月天數
    ' 建立日期  : 2003-05-16 15:20
    ' 作者      : 
    ' 輸入      : 無
    ' 返回      : 無
    ' 修改日期          作者          內容
    '
    '---------------------------------------------------------------------------------------
    Public Function gf_MonthDays(intYear As Integer, intMonth As Integer) As Integer
        Select Case intMonth
        Case 1, 3, 5, 7, 8, 10, 12
            gf_MonthDays = 31
        Case 4, 6, 9, 11
            gf_MonthDays = 30
        Case 2
            If (intYear Mod 4 = 0 And intYear Mod 100 <> 0) Or (intYear Mod 400 = 0) Then
                gf_MonthDays = 29
            Else
                gf_MonthDays = 28
            End If
        End Select
    End Function
      

  3.   

    DateSerial(CInt(cboYear), CInt(cboMonth)+1, 1-1)