ASP 格式化字符串输出
要做一个函数,输入年,月两个参数,返回字符串要求如下如,输入年=2009,月=5返回字符串"May2009"...
要做一个函数,输入 年,月两个参数,返回字符串要求如下
如,输入年=2009,月=5 返回 字符串"May 2009" 展开
如,输入年=2009,月=5 返回 字符串"May 2009" 展开
4个回答
展开全部
<%
'自定义函数
Function GMTtime(a,b)
Dim xx2wVar, xx2wToMonth
xx2wVar = a & "-" & b & "-" & c
If Not IsDate( xx2wVar ) Then
xx2wVar = Now
Else
xx2wVar = CDate( xx2wVar )
End If
xx2wToMonth = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
GMTtime = xx2wToMonth( Month( xx2wVar ) - 1 ) &" "&Year( xx2wVar )
End Function
'使用方法
response.write GMTtime(2009,5)
%>
'自定义函数
Function GMTtime(a,b)
Dim xx2wVar, xx2wToMonth
xx2wVar = a & "-" & b & "-" & c
If Not IsDate( xx2wVar ) Then
xx2wVar = Now
Else
xx2wVar = CDate( xx2wVar )
End If
xx2wToMonth = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
GMTtime = xx2wToMonth( Month( xx2wVar ) - 1 ) &" "&Year( xx2wVar )
End Function
'使用方法
response.write GMTtime(2009,5)
%>
展开全部
用一个判断啊.然后在拼接字符串.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ASP里有个日期转换,你可到网上找一下,我前几天在做这个呢!
可惜的是,我不是专学ASP的,也帮不了你!代码在网上可以找到的
可惜的是,我不是专学ASP的,也帮不了你!代码在网上可以找到的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
测试可用!直接拿去用吧!
<%
function getvalues(years,months)
if not (isnumeric(years) and isnumeric(months)) then
response.Write("参数错误")
exit function
end if
if months>12 then
response.Write("月份不能大于12")
exit function
end if
select case months
case "1"
getvalues="January "&years
case "2"
getvalues="February "&years
case "3"
getvalues="March "&years
case "4"
getvalues="April "&years
case "5"
getvalues="May "&years
case "6"
getvalues="June "&years
case "7"
getvalues="July "&years
case "8"
getvalues="August "&years
case "9"
getvalues="September "&years
case "10"
getvalues="October "&years
case "11"
getvalues="November "&years
case "12"
getvalues="December "&years
end select
end function
dim dated
dated=getvalues(2008,11)
response.Write dated
%>
<%
function getvalues(years,months)
if not (isnumeric(years) and isnumeric(months)) then
response.Write("参数错误")
exit function
end if
if months>12 then
response.Write("月份不能大于12")
exit function
end if
select case months
case "1"
getvalues="January "&years
case "2"
getvalues="February "&years
case "3"
getvalues="March "&years
case "4"
getvalues="April "&years
case "5"
getvalues="May "&years
case "6"
getvalues="June "&years
case "7"
getvalues="July "&years
case "8"
getvalues="August "&years
case "9"
getvalues="September "&years
case "10"
getvalues="October "&years
case "11"
getvalues="November "&years
case "12"
getvalues="December "&years
end select
end function
dim dated
dated=getvalues(2008,11)
response.Write dated
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询