輸出帶日期格式的隨機數(shù).asp
發(fā)表時間:2024-01-30 來源:明輝站整理相關軟件相關文章人氣:
[摘要]<%Function GetRanNum()'****************************************'函數(shù)名:GetRanNum'作 用:輸出帶日期格式的隨機數(shù)'參 數(shù):無 ----'返回值:如GetRanNum(),...
<%
Function GetRanNum()
'****************************************
'函數(shù)名:GetRanNum
'作 用:輸出帶日期格式的隨機數(shù)
'參 數(shù):無 ----
'返回值:如GetRanNum(),即輸出200409071553464617,為2004年09月07日15時53分46秒4617隨機數(shù)
'關聯(lián)函數(shù):FormatIntNumber
'****************************************
GetRanNum = ""
GetRanNum = GetRanNum&FormatIntNumber(year(now),4)
GetRanNum = GetRanNum&FormatIntNumber(month(now),2)
GetRanNum = GetRanNum&FormatIntNumber(day(now),2)
GetRanNum = GetRanNum&FormatIntNumber(hour(now),2)
GetRanNum = GetRanNum&FormatIntNumber(minute(now),2)
GetRanNum = GetRanNum&FormatIntNumber(second(now),2)
randomize
ranNum=int((9000*rnd)+1000)
GetRanNum = GetRanNum&ranNum
End Function
Function FormatIntNumber(Expression,Digit)
'****************************************
'函數(shù)名:FormatIntNumber
'作 用:輸出Digit位左邊帶0整數(shù)
'參 數(shù):Expression ----要格式化整數(shù)
'參 數(shù):Digit ----要格式化位數(shù)
'返回值:如0005,如FormatIntNumber(5,4),整數(shù)5被格式化為0005
'關聯(lián)函數(shù):無
'****************************************
While Len(Expression) < Digit
Expression = "0"&Expression
wend
FormatIntNumber = Expression
End Function
%><%
Function GetRanNum()
'****************************************
'函數(shù)名:GetRanNum
'作 用:輸出帶日期格式的隨機數(shù)
'參 數(shù):無 ----
'返回值:如GetRanNum(),即輸出200409071553464617,為2004年09月07日15時53分46秒4617隨機數(shù)
'關聯(lián)函數(shù):FormatIntNumber
'****************************************
GetRanNum = ""
GetRanNum = GetRanNum&FormatIntNumber(year(now),4)
GetRanNum = GetRanNum&FormatIntNumber(month(now),2)
GetRanNum = GetRanNum&FormatIntNumber(day(now),2)
GetRanNum = GetRanNum&FormatIntNumber(hour(now),2)
GetRanNum = GetRanNum&FormatIntNumber(minute(now),2)
GetRanNum = GetRanNum&FormatIntNumber(second(now),2)
randomize
ranNum=int((9000*rnd)+1000)
GetRanNum = GetRanNum&ranNum
End Function
Function FormatIntNumber(Expression,Digit)
'****************************************
'函數(shù)名:FormatIntNumber
'作 用:輸出Digit位左邊帶0整數(shù)
'參 數(shù):Expression ----要格式化整數(shù)
'參 數(shù):Digit ----要格式化位數(shù)
'返回值:如0005,如FormatIntNumber(5,4),整數(shù)5被格式化為0005
'關聯(lián)函數(shù):無
'****************************************
While Len(Expression) < Digit
Expression = "0"&Expression
wend
FormatIntNumber = Expression
End Function
%>