首页 > 学院 > 编程设计 > 正文

如何利用当前时间生成随机函数?

2020-06-19 13:50:23
字体:
来源:转载
供稿:网友

quote.asp

<%
Set MyFileObj = Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile = MyFileObj.OpenTextFile("c:/quote.txt")

' 设置好路径.
IF NOT MyTextFile.AtEndOfStream THEN
header = CInt(MyTextFile.ReadLine)

' 读表头.

END IF
RANDOMIZE

' 生成基于表头的随机数, RANDOMIZE语句对确保一个随机数非常重要.
RandomValue = INT(header*RND)+1
Count=0
'
循环直到行号等于随机数,保存在变量引用.
WHILE NOT MyTextFile.AtEndOfStream AND NOT Count = RandomValue
quote = MyTextFile.ReadLine
Count = Count + 1
WEND
'
关闭文本文件.
MyTextFile.Close
%>
<html>

<body>
现在引用的是: <%=quote%>
</body></html>

[1]

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表