ASP常用函数收藏乱七八糟未整理版(39)
Dim zNum, zNum2
Randomize
zNum = CInt(25 * Rnd)
zNum2 = CInt(10 * Rnd)
If zNum2 Mod 2 = 0 Then
zNum = zNum + 97
Else
zNum = zNum + 65
End If
thechr = thechr & Chr(zNum)
Next
MyRandc = thechr
End Function
Function MyRandn(n) '生成随机数字,n为数字的个数
Dim thechr
thechr = ""
For i = 1 To n
Dim zNum, zNum2
Randomize
zNum = CInt(9 * Rnd)
zNum = zNum + 48
thechr = thechr & Chr(zNum)
Next
MyRandn = thechr
End Function
Function formatQueryStr(Str) '格式化sql中的like字符串
Dim nstr
nstr = Str
nstr = Replace(nstr, Chr(0), "")
nstr = Replace(nstr, "'", "''")
nstr = Replace(nstr, "[", "[[]")
nstr = Replace(nstr, "%", "[%]")
formatQueryStr = nstr
End Function
Function GetRnd(min, max)
Randomize
GetRnd = Int((max - min + 1) * Rnd + min)
End Function
'*******************************************************************
'取得IP地址
'*******************************************************************
Function Userip()
Dim GetClientIP
'如果客户端用了代理服务器,则应该用ServerVariables("HTTP_X_FORWARDED_FOR")方法
GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If GetClientIP = "" or IsNull(GetClientIP) or IsEmpty(GetClientIP) Then
内容版权声明:除非注明,否则皆为本站原创文章。