WEB开发网
开发学院WEB开发ASP 文本文件的内容进行排序 阅读

文本文件的内容进行排序

 2012-05-19 13:04:37 来源:WEB开发网   
核心提示:Dim objFSO,objFile,DataList,strTextConst adVarChar = 200 Const MaxCharacters = 255 Const ForReading = 1 Const ForWriting = 2 Set DataList = CreateObject("A
Dim objFSO,objFile,DataList,strText
Const adVarChar = 200 
Const MaxCharacters = 255 
Const ForReading = 1 
Const ForWriting = 2 

Set DataList = CreateObject("ADOR.Recordset") 
DataList.Fields.Append "ComputerName", adVarChar, MaxCharacters 
DataList.Open 

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFile = objFSO.OpenTextFile("C:ScriptsComputers.txt", ForReading) 

Do Until objFile.AtEndOfStream 
strLine = objFile.ReadLine 
DataList.AddNew 
DataList("ComputerName") = strLine 
DataList.Update 
Loop 

objFile.Close 

DataList.Sort = "ComputerName" 

DataList.MoveFirst 
Do Until DataList.EOF 
strText = strText & DataList.Fields.Item("ComputerName") & vbCrLf 
DataList.MoveNext 
Loop 

Set objFile = objFSO.OpenTextFile("C:ScriptsComputers.txt", ForWriting) 

objFile.WriteLine strText 
objFile.Close

Tags:文本 文件 进行

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接