中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

vbs刪除文本文件的行的函數(shù)
來源:易賢網(wǎng) 閱讀:2795 次 日期:2016-07-20 14:49:32
溫馨提示:易賢網(wǎng)小編為您整理了“vbs刪除文本文件的行的函數(shù)”,方便廣大網(wǎng)友查閱!

有時(shí)候我們需要?jiǎng)h除文本文件的指定的一行內(nèi)容,下面是具體的函數(shù)

Delete Line Function

代碼如下:

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

更多信息請查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:vbs刪除文本文件的行的函數(shù)
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2026國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)
主站蜘蛛池模板: 塔河县| 闽侯县| 沅陵县| 尚义县| 宁夏| 仁化县| 利辛县| 和平区| 鄄城县| 奉节县| 兴山县| 中山市| 东港市| 云龙县| 观塘区| 阳曲县| 阿城市| 永福县| 中牟县| 东乡族自治县| 新干县| 巨野县| 哈尔滨市| 南郑县| 桐城市| 宜丰县| 临汾市| 丹江口市| 灵川县| 金沙县| 佛冈县| 高邮市| 饶阳县| 马尔康县| 宜丰县| 汉阴县| 明溪县| 改则县| 叶城县| 邻水| 涿鹿县|