作者: gezhirong 时间: 2011-6-2 00:19
Function TxtReadLines(txtPath,delimiter)
Dim objDictionary,objFso,objTxtFile
Dim strReadLine,splitReadLine
Dim lineCount
Set objDictionary=CreateObject("Scripting.Dictionary")
Set objFso=CreateObject("Scripting.FileSystemObject")
Set objTxtFile=objFso.OpenTextFile(txtPath,1,true)
Do while not(objTxtFile.AtEndOfStream)
strReadLine=objTxtFile.ReadLine
objTxtFile.SkipLine
If instr(strReadLine,delimiter)>0 Then
lineCount=lineCount+1
splitReadLine=split(strReadLine,delimiter)
objDictionary.Add "left"&cstr(lineCount),trim(splitReadLine(0))
objDictionary.Add "right"&cstr(lineCount),trim(splitReadLine(1))
End If
loop
Set objTxtFile=nothing
Set objFso=nothing
Set TxtReadLines=objDictionary
Set objDictionary=nothing
End Function
'传递文件的路径和分隔符,比如你说的等号
Set txtDic=TxtReadLines("d:\text.txt","=")
For i=1 to txtDic.count/2
'等号左边的值
msgbox txtDic.Item("left"&cstr(i))
'等号右边的值
msgbox txtDic.Item("right"&cstr(i))
Next作者: gezhirong 时间: 2011-6-2 00:20
Function TxtReadLines(txtPath,delimiter)
Dim objDictionary,objFso,objTxtFile
Dim strReadLine,splitReadLine
Dim lineCount
Set objDictionary=CreateObject("Scripting.Dictionary")
Set objFso=CreateObject("Scripting.FileSystemObject")
Set objTxtFile=objFso.OpenTextFile(txtPath,1,true)
作者: gezhirong 时间: 2011-6-2 00:21
Function TxtReadLines(txtPath,delimiter)
Dim objDictionary,objFso,objTxtFile
Dim strReadLine,splitReadLine
Dim lineCount
Set objDictionary=CreateObject("Scripting.Dictionary")
Set objFso=CreateObject("Scripting.FileSystemObject")
Set objTxtFile=objFso.OpenTextFile(txtPath,1,true)
Do while not(objTxtFile.AtEndOfStream)
strReadLine=objTxtFile.ReadLine
objTxtFile.SkipLine
If instr(strReadLine,delimiter)>0 Then
lineCount=lineCount+1
splitReadLine=split(strReadLine,delimiter)
objDictionary.Add "left"&cstr(lineCount),trim(splitReadLine(0))
objDictionary.Add "right"&cstr(lineCount),trim(splitReadLine(1))
End If
loop
Set objTxtFile=nothing
Set objFso=nothing
Set TxtReadLines=objDictionary
Set objDictionary=nothing
End Function
'传递文件的路径和分隔符,比如你说的等号
Set txtDic=TxtReadLines("d:\text.txt","=")
For i=1 to txtDic.count/2
'等号左边的值
msgbox txtDic.Item("left"&cstr(i))
'等号右边的值
msgbox txtDic.Item("right"&cstr(i))
Next作者: 43528782 时间: 2011-6-2 09:27
顶~作者: gezhirong 时间: 2011-6-2 09:35
Function TxtReadLines(txtPath,delimiter)
Dim objDictionary,objFso,objTxtFile
Dim strReadLine,splitReadLine
Dim lineCount
Set objDictionary=CreateObject("Scripting.Dictionary")
Set objFso=CreateObject("Scripting.FileSystemObject")
Set objTxtFile=objFso.OpenTextFile(txtPath,1,true)