Dim year As Integer
Dim month As Integer
Dim day As Integer
Dim str As String
Dim mydate As Date
year = 1999
month = 3
day = 23
str = CStr(year) & "-" & CStr(month) & "-" & CStr(day)
mydate = Format(str, "yy-mm-dd")
MsgBox mydate

解决方案 »

  1.   

    dim year as integer
    dim month as integer
    dim day as integer
    dim chargetime as date
    dim Str as stringstr=year & "-" & month & "-" & day
    chargetime=cdate(str)
      

  2.   

    它怎么说 mydate=format(str,"yy-mm-dd")中变量未设置?
      

  3.   

    dim year as integer
    dim month as integer
    dim day as integer
    dim chargetime as date
    chargetime=DateSerial(year,month,day)
      

  4.   

    DateSerial
    DateSerial(2002,4,31)=#2002-5-1#
      

  5.   

    chargetime = CDate (year & "-" & month & "-" & "day")