写一个转换函数
Private Function strREV(dtrDate As String) As String
Dim strStdioDate As String
Dim strTemp As String
Dim iLen As Integer
iLen = InStrRev(dtrDate, "-")
If iLen > 0 Then
strStdioDate = Left(dtrDate, iLen - 1)
strTemp = Right(dtrDate, Len(dtrDate) - iLen)
strTemp = strTemp & ":00:00"
strStdioDate = strStdioDate & " " & strTemp
strREV = strStdioDate
Else
strREV = dtrDate
End If
End Function
测试在win2000下通过
Private Sub Command1_Click()
'没加错误处理,你自己加吧
Dim arrtemp As Variant
arrtemp = Split(Text1.Text, "-")
Dim mydate As Date
mydate = DateSerial(arrtemp(0), arrtemp(1), arrtemp(2)) + TimeSerial(arrtemp(3), 0, 0)
MsgBox Hour(mydate)
MsgBox Day(mydate)
MsgBox Month(mydate)
MsgBox Year(mydate)
End Sub