Ghost全自动系统备份光盘正式版 V4.5 | 硬盘版 V2.0 | 排行榜 TOP50 | 图文推荐 | 玩小游戏
首页 >> Asp编程 >> Asp新手入门 >> asp生成带日期的随机数

asp生成带日期的随机数

作者:亮亮 来源:亮亮blog 时间:2008-9-3 网友评论条 【

很简单的一个函数,就是根据当前的日期生成一个随机数。

<%
Function getRnd()
'****************************************
'返回值:如getRnd(),即输出200808241553464617,为2008年08月24日15时53分46秒4617随机数
'关联函数:formatInt()
'****************************************
getRnd = ""
getRnd = getRnd&formatInt(year(now),4)
getRnd = getRnd&formatInt(month(now),2)
getRnd = getRnd&formatInt(day(now),2)
getRnd = getRnd&formatInt(hour(now),2)
getRnd = getRnd&formatInt(minute(now),2)
getRnd = getRnd&formatInt(second(now),2)
randomize
ranNum=int((9000*rnd)+1000)
    getRnd = getRnd&ranNum
End Function

Function formatInt(Expression,Digit)
'****************************************
'函数名:formatInt
'作  用:输出Digit位左边带0整数
'参  数:Expression   ----要格式化整数
'参  数:Digit        ----要格式化位数
'返回值:如006,如FormatIntNumber(6,3),整数5被格式化为006
'关联函数:无
'****************************************
While Len(Expression) < Digit
  Expression = "0"&Expression
wend
formatInt = Expression
End Function

response.Write(getRnd()&"<br>")
response.Write(formatInt(24,5))'输出00024
%>

站长工具
Google 相关搜索查询:
相关文章
loading 请稍等,评论加载中...

Aspxhome.com. 中国Asp之家. 版权所有

闽ICP备06017341号