我一行一行读一个文本,合以来却并成一行,请问如何保持原来的分行

fgwr 2001-07-23 12:28:52
我一行行读一个文件,在每行前和后加些字符,用一个变量将这些都 加起来,但最后成了一行。有什么方法保持原来的分行啊?



...全文
110 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
is 2001-09-16
  • 打赏
  • 举报
回复
哎。。
我知道这是我想要的。
但不懂。。
解答一下。
tripofdream 2001-07-23
  • 打赏
  • 举报
回复
>>在每行前和后加些字符
顺便加上回车就行
BrentIvan 2001-07-23
  • 打赏
  • 举报
回复
sContent = ""
Do While Not ts.AtEndOfStream ' ts is your TextStream Object
sContent = sContent & ts.ReadLine & "<br>"
Loop
Response.Write(sContent)
fgwr 2001-07-23
  • 打赏
  • 举报
回复
多谢几位
hydnoahark 2001-07-23
  • 打赏
  • 举报
回复
自己加vbCRLF即可
wingc 2001-07-23
  • 打赏
  • 举报
回复
那就用vbCrlf

......
sContent = sContent & txt.ReadLine & vbCrlf
......
其实就是ASCII中的换行符和回车符
孟子E章 2001-07-23
  • 打赏
  • 举报
回复
WriteLine Method:

Writes a specified string and newline character to a TextStream file.

object.WriteLine([string])

Arguments:

object:
Required. Always the name of a TextStream object.

string:
Optional. The text you want to write to the file. If omitted, a newline character is written to the file.

Remarks
The following example illustrates use of the WriteLine method:

Function WriteLineToFile
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.WriteLine "Hello world!"
f.WriteLine "VBScript is fun!"
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
WriteLineToFile = f.ReadAll
End Function
fgwr 2001-07-23
  • 打赏
  • 举报
回复
能不能不用<BR>?因为我的文件不是在网页上显示
wybm 2001-07-23
  • 打赏
  • 举报
回复
<%
set fso=server.CreateObject("scripting.filesystemobject")
text_file="The open file"
set txt=.OpenTextFile(text_file,1,false)
Do While Not txt.AtEndOfStream
sContent = sContent & txt.ReadLine & "<br>"
loop
Response.Write(sContent)
%>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧