首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  从当前时间来取得随机数

7i24.Com不停为您服务
从当前时间来取得随机数

<%
'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"-->


  2002年1月9日  阅读 878 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 用ASP编写农历算法(三)
下一篇: 支持中文的把普通字符串转成二进制字符串的函数
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利