最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vbs刪除文本文件的行的函數(shù)

 更新時(shí)間:2008年10月24日 00:57:24   作者:  
有時(shí)候我們需要?jiǎng)h除文本文件的指定的一行內(nèi)容,下面是具體的函數(shù)
Delete Line Function
復(fù)制代碼 代碼如下:

Function DeleteLine(strFile, strKey, LineNumber, CheckCase)
'DeleteLine Function by TomRiddle 2008

'Remove line(s) containing text (strKey) from text file (strFile)
'or
'Remove line number from text file (strFile)
'or
'Remove line number if containing text (strKey) from text file (strFile)

'Use strFile = "c:\file.txt" (Full path to text file)
'Use strKey = "John Doe" (Lines containing this text string to be deleted)
'Use strKey = "" (To not use keyword search)
'Use LineNumber = "1" (Enter specific line number to delete)
'Use LineNumber = "0" (To ignore line numbers)
'Use CheckCase = "1" (For case sensitive search )
'Use CheckCase = "0" (To ignore upper/lower case characters)


Const ForReading=1:Const ForWriting=2
Dim objFSO,objFile,Count,strLine,strLineCase,strNewFile
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile=objFSO.OpenTextFile(strFile,ForReading)
Do Until objFile.AtEndOfStream
strLine=objFile.Readline
If CheckCase=0 then strLineCase=ucase(strLine):strKey=ucase(strKey)
If LineNumber=objFile.Line-1 or LineNumber=0 then
If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey="" then
strNewFile=strNewFile
Else
strNewFile=strNewFile&strLine&vbcrlf
End If
Else
strNewFile=strNewFile&strLine&vbcrlf
End If
Loop
objFile.Close
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile=objFSO.OpenTextFile(strFile,ForWriting)
objFile.Write strNewFile
objFile.Close

End Function

使用方法:
DeleteLine "c:\1.txt", "", 1, 0

相關(guān)文章

最新評(píng)論

本溪市| 淮阳县| 温泉县| 尼勒克县| 黄浦区| 新建县| 高邮市| 尉犁县| 开封县| 遵化市| 清河县| 丹江口市| 文成县| 昭苏县| 永丰县| 新宾| 福建省| 临漳县| 大庆市| 德阳市| 和静县| 平遥县| 襄城县| 安西县| 历史| 定远县| 韶山市| 开江县| 同心县| 富川| 北安市| 颍上县| 亳州市| 海门市| 化州市| 龙州县| 遵义市| 马关县| 乌什县| 开江县| 大埔县|