'随机字体
'##############################################
'# 取得一个随机字体大小
'##############################################
Public Function GetRandomFont()
dim f1,f2,f3,f4,f5,f6,f7 '字体
f1 = "14pt"
f2 = "13pt"
f3 = "12pt"
f4 = "10pt"
f5 = "9pt"
f6 = "8pt"
f7 = "16pt"
dim rno
rno = GetRandomStr(1,0)
'response.Write "<br>rno:"&rno
select case rno
case "1"
GetRandomFont = f1
case "2"
GetRandomFont = f2
case "3"
GetRandomFont = f3
case "4"
GetRandomFont = f4
case "5"
GetRandomFont = f5
case "6"
GetRandomFont = f6
case "7"
GetRandomFont = f7
case else
GetRandomFont = f5
end select
'response.Write GetRandomFont
End Function
'随机颜色
'##############################################
'# 取得一个随机字符串
'##############################################
Public Function GetRandomColor()
dim c1,c2,c3,c4,c5,c6,c7,c8,c9 '颜色
c1 = "#000000"
c2 = "#7A7A7A"
c3 = "#FD0000"
c4 = "#003062"
c5 = "#010C4B"
c6 = "#32014B"
c7 = "#4B011D"
c8 = "#002E28"
c9 = "#C15B00"
dim rno2
rno2 = GetRandomStr(1,0)
'response.Write "<br>rno2:"&rno2
select case rno2
case "1"
GetRandomColor = c1
case "2"
GetRandomColor = c2
case "3"
GetRandomColor = c3
case "4"
GetRandomColor = c4
case "5"
GetRandomColor = c5
case "6"
GetRandomColor = c6
case "7"
GetRandomColor = c7
case "8"
GetRandomColor = c8
case "9"
GetRandomColor = c9
case else
GetRandomColor = c1
end select
'response.Write GetRandomColor
End Function
'随机函数
'##############################################
'# 取得一个随机字符串
'# digits:欲得到多少位随机字符
'# stype:随机串中包含的字符类型
'# 0, 只包含数字
'# l, 只包含小写字母
'# u, 只包含大写字母
'# c, 大/小写字母
'# s, 各种符号
'# a, 字母与数字
'# , 包含以上所有的
'##############################################
Public Function GetRandomStr(digits,stype)
If Not IsNumeric(digits) Then
digits = 0
else
digits = clng(digits)
End If
dim dict
If 0=digits Then Exit Function
select case lcase(stype)
case "0"
dict = "0123456789"
case "l"
dict = "abcdefghijklmnopqrstuvwxyz"
case "u"
dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
case "c"
dict = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
case "a"
dict = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
case "s"
dict = "`~!@#$%^&()_+-=[]{};,.* <> /\|:? "
case else
dict = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&()_+-=[]{};,.* <> /\|:? "
end select
do
randomize
GetRandomStr = GetRandomStr & mid(dict,int(len(dict)*rnd)+1,1)
'int(len(dict)*rnd)+1 加1防止出错
If len(GetRandomStr) >= digits Then exit do
loop
GetRandomStr = left(GetRandomStr,digits)
End Function
最新评论