2
我做了一個名爲FormatDT功能時,我把它放在\include\basic_function.asp
錯誤「800a005e」無效使用Null:「CDATE」使用ASP經典,VBScript中的函數
這裏是函數的代碼:
function FormatDT(ddate,format)
ddate = cdate(ddate)
Set re = New RegExp
re.Pattern = "%."
re.Global = True
re.IgnoreCase = False
're.MultiLine = True
set matches = re.execute(format)
hasil = ""
tmp = format
for each match in matches
fmt = match.value
select case fmt
case "%d" hasil = day(ddate)
case "%D" hasil = right("00" & day(ddate),2)
case "%m" hasil = month(ddate)
case "%M" hasil = right("00" & month(ddate),2)
case "%b" hasil = left(MonthName(month(ddate)),3)
case "%B" hasil = MonthName(month(ddate))
case "%y" hasil = right(year(ddate),2)
case "%Y" hasil = year(ddate)
case "%h" hasil = hour(ddate)
case "%H" hasil = right("00" & hour(ddate),2)
case "%n" hasil = minute(ddate)
case "%N" hasil = right("00" & minute(ddate),2)
case "%s" hasil = second(ddate)
case "%S" hasil = right("00" & second(ddate),2)
case else hasil = replace(fmt,"%","")
end select
tmp = replace(tmp,fmt,hasil)
next
FormatDT = tmp
end function
我在這裏使用此功能:
<input style="text-align:center" class="label" style="width:6em;" type="text" id="txtDate" name="txtDate" size="12" value="<%=FormatDt(dtglvalid,"%M/%D/%Y")%>" >
,當網頁加載完畢後,我得到了這樣的錯誤消息:
Microsoft VBScript運行時錯誤 '800a005e' 無效使用Null: 'CDATE'
/include/basic_function.asp,線234
線234位於ddate = cdate(ddate)
如何解決這個錯誤?
好吧,它的工作原理!多謝,夥計 :) – blankon91