要求:如果用户发表一个帖子(或者其他登录一次什么的)就显示一个星星×发两个就2个×, 发4个就是月亮了, 16个就是一个太阳.
方法如下:
<%
response.write Grade(38)
function Grade(count)
if count<4 then
Grade = String1(count,"star")
else
if count<16 then
Grade = String1((count\4),"moon") & String1((count mod 4),"star")
else
Grade = String1((count\16),"sun") & String1(((count mod 16)\4),"moon") & String1((count mod 4),"star")
end if
end if
end function
function String1(count,content)
dim i, str
str = ""
content = "<img src='" & content & ".gif' alt='' />"
for i=1 to count
str = str & content
next
String1 = str
end function
%>
这代码算法部分是关键. 显示部分可以根据自己的需要来改.
response.write String(count,"星")
String是内置函数, 将一个字符重复N次, count代表要重复的次数, 不过只重复第一个字符. 你如果要显示图片, 建议可以做几个图片statr1.gif, statr2.gif, statr3.gif
然后这样
response.write "<img src='star" & count & ".gif'>"
如果觉得做图片麻烦, 可以写个自定义的String函数
function String1(count,content)
dim i, str
str = ""
for i=1 to count
str = str & content
next
String1 = str
end function
然后调用时
response.write String1(count,"<img src=http://www.17buyhost.com/article/""star.gif"" >")
![]()
由于各种原因,我们无法获知[利用ASP实现QQ等级的方法]原创作者,如侵犯了您的版权,请您及时联系我们!

