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]