从当前时间来取得随机数

作者在 2006-11-14 19:00:00 发布以下内容
<%
'First we open the banner file, make sure you have the right path to
the file
Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile = MyFileObj.OpenTextFile("c:\quote.txt")
'Then we read the header
IF NOT MyTextFile.AtEndOfStream THEN
header = CInt(MyTextFile.ReadLine)
END IF
'Then we make a random value based on the header, the RANDOMIZE
'statement is important to insure a random value.
RANDOMIZE
RandomValue = INT(header*RND)+1
Count=0
'Loops until it comes to line number=random value
'And then it saves it in the variable quote
WHILE NOT MyTextFile.AtEndOfStream AND NOT Count = RandomValue
quote = MyTextFile.ReadLine
Count = Count + 1
WEND
'Closeing up the text file
MyTextFile.Close
%>
<HTML><BODY>
Todays quote is: <%=quote%>
</BODY></HTML>

要用的时候只要用包含文件把它包含进来就可以了
<!--#INCLUDE VIRTUAL="/quote.asp"-->

宝贝资料 | 阅读 1029 次
文章评论,共0条
游客请输入验证码