日期:2014-05-17  浏览次数:20908 次

获取项目号方法?
我做外包项目,外包成功需要返回一个项目号,项目号的产生要求是取年的后两位数 + 任意8位数字+ 1个字母 即可,请各位帮我下!谢谢!

------解决方案--------------------
asp随机生成8位数字与字母组合 供参考:
取年的后两位:Right(year(now(),2))
<%
Function Createpass(LengthNum)
Dim Ran,i
if Not IsNumeric(LengthNum) then LengthNum=8
Createpass=""
For i=1 To LengthNum
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
Createpass = Createpass & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& Chr(Ran)
End If
Next
End Function
dim num
num =Createpass(8)
Response.Write num
%>


------解决方案--------------------
VBScript code

<%
Response.Write getPrjNum()

Function getPrjNum()
    getPrjNum = Right(Year(Date),2) & genNum(8, 8) & UCase(genStr(1,1))
End Function

Function randNum(lowerbound, upperbound)
    Randomize Time()
    randNum =  Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
End Function

Function genStr(n, m)
    Dim a, z, s, i, p
    a = Asc("a")
    z = Asc("z")
    s = ""
    p = randNum(n, m)
    For i = 1 To p
        s = s & Chr(randNum(a, z))
    Next
    genStr = s
End Function

Function genNum(n, m)
    Dim a, z, s, i, p
    a = Asc("0")
    z = Asc("9")
    s = ""
    p = randNum(n, m)
    For i = 1 To p
        s = s & Chr(randNum(a, z))
    Next
    genNum = s
End Function
%>