dim str_dtime as date
  str_dtime = 2002-05-15
我要得到的结果为是在月份后面加两个月/.
  得到为  str_dtime = 2002-07-15请问在vb中怎么实现哦

解决方案 »

  1.   

    Option ExplicitPrivate Sub Command1_Click()
        Call MsgBox(Test("2002-07-15"))
    End SubPrivate Function Test(ByVal strData As String) As String
        Dim intMonth As Integer, intYear As Integer, intDay As Integer, strResult As String
        
        intMonth = Month(CDate(strData))
        intYear = Year(CDate(strData))
        intDay = Day(CDate(strData))
        strResult = IIf(intMonth + 2 > 12, intYear + 1 & "-" & intMonth + 2 - 12 & "-" & intDay, intYear & "-" & intMonth + 2 & "-" & intDay)
        strResult = Format(strResult, "YYYY-MM-DD")
        
        Test = strResult
    End Function