函数调用的时候“类型不匹配”?大家帮我看看是怎么回事!!!

john2008lyb 2003-10-15 12:31:03
asp文件如下:
<script>
'======================================================
' 函数 Date2Chinese
' 功能:获得中文日期的字符串(如一九九八年五月十二日)
' 参数: iDate 要转化的日期
' 返回: 中文日期的字符串
'======================================================
Function Date2Chinese(iDate)
    Dim num(10)
    Dim iYear
    Dim iMonth
    Dim iDay

    num(0) = "〇"
    num(1) = "一"
    num(2) = "二"
    num(3) = "三"
    num(4) = "四"
    num(5) = "五"
    num(6) = "六"
    num(7) = "七"
    num(8) = "八"
    num(9) = "九"

    iYear = Year(iDate)
    iMonth = Month(iDate)
    iDay = Day(iDate)
    Date2Chinese = num(iYear \ 1000) + _
        num((iYear \ 100) Mod 10) + num((iYear _
        \ 10) Mod 10) + num(iYear Mod _
        10) + "年"
    If iMonth >= 10 Then
        If iMonth = 10 Then
            Date2Chinese = Date2Chinese + _
            "十" + "月"
        Else
            Date2Chinese = Date2Chinese + _
            "十" + num(iMonth Mod 10) + "月"
        End If
    Else
        Date2Chinese = Date2Chinese + _
            num(iMonth Mod 10) + "月"
    End If
    If iDay >= 10 Then
        If iDay = 10 Then
            Date2Chinese = Date2Chinese + _
            "十" + "日"
        ElseIf iDay = 20 Or iDay = 30 Then
            Date2Chinese = Date2Chinese + _
            num(iDay \ 10) + "十" + "日"
        ElseIf iDay > 20 Then
            Date2Chinese = Date2Chinese + _
            num(iDay \ 10) + "十" + _
            num(iDay Mod 10) + "日"
        Else
           Date2Chinese = Date2Chinese + _
           "十" + num(iDay Mod 10) + "日"
        End If
    Else
        Date2Chinese = Date2Chinese + _
        num(iDay Mod 10) + "日"
    End If
End Function
</script>

<%
response.write date2Chinese(date())
%>

运行时显示如下:

Microsoft VBScript 运行时错误 错误 '800a000d'

类型不匹配: 'date2Chinese'

/book/1.asp,行68
...全文
116 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyf_321 2003-10-15
  • 打赏
  • 举报
回复
<%
Function Date2Chinese(iDate)
    Dim num(10)
    Dim iYear
    Dim iMonth
    Dim iDay

    num(0) = "〇"
    num(1) = "一"
    num(2) = "二"
    num(3) = "三"
    num(4) = "四"
    num(5) = "五"
    num(6) = "六"
    num(7) = "七"
    num(8) = "八"
    num(9) = "九"

    iYear = Year(iDate)
    iMonth = Month(iDate)
    iDay = Day(iDate)
    Date2Chinese = num(iYear \ 1000) + _
        num((iYear \ 100) Mod 10) + num((iYear _
        \ 10) Mod 10) + num(iYear Mod _
        10) + "年"
    If iMonth >= 10 Then
        If iMonth = 10 Then
            Date2Chinese = Date2Chinese + _
            "十" + "月"
        Else
            Date2Chinese = Date2Chinese + _
            "十" + num(iMonth Mod 10) + "月"
        End If
    Else
        Date2Chinese = Date2Chinese + _
            num(iMonth Mod 10) + "月"
    End If
    If iDay >= 10 Then
        If iDay = 10 Then
            Date2Chinese = Date2Chinese + _
            "十" + "日"
        ElseIf iDay = 20 Or iDay = 30 Then
            Date2Chinese = Date2Chinese + _
            num(iDay \ 10) + "十" + "日"
        ElseIf iDay > 20 Then
            Date2Chinese = Date2Chinese + _
            num(iDay \ 10) + "十" + _
            num(iDay Mod 10) + "日"
        Else
           Date2Chinese = Date2Chinese + _
           "十" + num(iDay Mod 10) + "日"
        End If
    Else
        Date2Chinese = Date2Chinese + _
        num(iDay Mod 10) + "日"
    End If
End Function
response.write Date2Chinese(date)

%>
yyf_321 2003-10-15
  • 打赏
  • 举报
回复
<%
response.write Date2Chinese(date)
%>
007james 2003-10-15
  • 打赏
  • 举报
回复
可以这样直接调用吗?
尝试下:

<%
response.write "<script>"
response.write date2Chinese(date())
response.write "</script>"
%>
xiaobird1 2003-10-15
  • 打赏
  • 举报
回复
<%
'======================================================
' 函数 Date2Chinese
' 功能:获得中文日期的字符串(如一九九八年五月十二日)
' 参数: iDate 要转化的日期
' 返回: 中文日期的字符串
'======================================================
Function Date2Chinese(iDate)
Dim num(10)
Dim iYear
Dim iMonth
Dim iDay

num(0) = "〇"
num(1) = "一"
num(2) = "二"
num(3) = "三"
num(4) = "四"
num(5) = "五"
num(6) = "六"
num(7) = "七"
num(8) = "八"
num(9) = "九"

iYear = Year(iDate)
iMonth = Month(iDate)
iDay = Day(iDate)
Date2Chinese = num(iYear \ 1000) + _
num((iYear \ 100) Mod 10) + num((iYear _
\ 10) Mod 10) + num(iYear Mod _
10) + "年"
If iMonth >= 10 Then
If iMonth = 10 Then
Date2Chinese = Date2Chinese + _
"十" + "月"
Else
Date2Chinese = Date2Chinese + _
"十" + num(iMonth Mod 10) + "月"
End If
Else
Date2Chinese = Date2Chinese + _
num(iMonth Mod 10) + "月"
End If
If iDay >= 10 Then
If iDay = 10 Then
Date2Chinese = Date2Chinese + _
"十" + "日"
ElseIf iDay = 20 Or iDay = 30 Then
Date2Chinese = Date2Chinese + _
num(iDay \ 10) + "十" + "日"
ElseIf iDay > 20 Then
Date2Chinese = Date2Chinese + _
num(iDay \ 10) + "十" + _
num(iDay Mod 10) + "日"
Else
Date2Chinese = Date2Chinese + _
"十" + num(iDay Mod 10) + "日"
End If
Else
Date2Chinese = Date2Chinese + _
num(iDay Mod 10) + "日"
End If
End Function



response.write date2Chinese(cstr(date()))
%>
yumeiren777 2003-10-15
  • 打赏
  • 举报
回复
<Script Language=VBScript>
ppp()
</Script>
john2008lyb 2003-10-15
  • 打赏
  • 举报
回复
<html>
<head>
<title>1111</title>
</head>
<Script Language=VBScript>
function ppp()
msgbox "asdfasfsafsaf"
end function
</Script>
<body text="#FF0000" bgcolor="#00FFCC">
……
</body>
</html>

在body中调用函数ppp该怎么写

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧