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] |
请发表评论