您当前的位置:易搜源码站网络编程ASP编程 → 文章内容
RSS订阅

用ASP读取显示TXT文件内容的代码

作者:佚名  来源:yscode.com整理  发布时间:2007-11-6 12:59:50

<html><head><title>基于文本的消息发布系统</title></head>
<body>
<table border="1" cellspacing="0" cellpadding="1" bordercolorlight="#dfdfdf" bordercolordark="#ffffff" align="center">
<tr bgcolor="#cccce6">
<td algin="center" colspan="2">最新消息</td>
</tr>
<%
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fp=fso.OpenTextFile(Server.MapPath("message.txt"))
'打开message.txt

Do While fp.AtEndOfStream<>true
s=fp.ReadLine '读取一条数据

p=Instr(s,"*") '取得*号的位置
Messagetitle=Mid(s,1,p-1) '取得*号前边的字符串(消息标题)
s=Mid(s,p+1,Len(s)-p) '设变量s为*号后边的字符串

p=Instr(s,"*")
MessageUrl=Mid(s,1,p-1) '取得*号后边的字符串(链接地址)
s=Mid(s,p+1,Len(s)-p)

ttime=s '设定消息发布时间ttime为s
%>
<tr>

<td><a href='<%=MessageUrl%>'><%=Messagetitle%></a></td>
<td><%=ttime%></td>
</tr>
<!--生成表格,把消息显示出来-->
<%
Loop
Fp.close
Set fp=Nothing
Set fso=Nothing
%>
</table>
</body></html>


文章评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码