转换问题???
dim str_dtime as date
str_dtime = 2002-05-15
我要得到的结果为是在月份后面加两个月/.
得到为 str_dtime = 2002-07-15
请问在vb中怎么实现哦
[解决办法]
Option Explicit
Private Sub Command1_Click()
Call MsgBox(Test( "2002-07-15 "))
End Sub
Private 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