Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Delete Line Function

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,63517
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Delete Line Function
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Delete Line Function - 8/15/2008 11:28:37 PM   
  TomRiddle


Posts: 191
Score: 4
Joined: 2/7/2008
Status: offline
'VBScript does not have a simple function for removing a line from a file.
'After doing a search and not finding anything decent, I wrote this function.

'Examples
option explicit

'DeleteLine "c:\test.txt", "qwerty", 0, 0
'If script finds text qwerty on any line in text file c:\text.txt it will delete that line

'DeleteLine "c:\test.txt", "", 17, 0
'Script deletes line 17 in text file c:\text.txt

DeleteLine "c:\test.txt", "qwerty", 17, 0
'If script finds text qwerty on line 17 in text file c:\text.txt it will delete that line




      

< Message edited by TomRiddle -- 8/16/2008 8:32:32 PM >
 
 
Revisions: 1 | Post #: 1
 
 RE: Delete Line Function - 8/16/2008 4:38:38 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You know that there is a Line property that shows you the line number right?  objFile.Line 
Also, since this may come in useful to some....maybe add the ability have it be case-sensitive or not.

< Message edited by dm_4ever -- 8/17/2008 2:26:43 PM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to TomRiddle)
 
 
Revisions: 1 | Post #: 2
 
 RE: Delete Line Function - 8/16/2008 8:33:50 PM   
  TomRiddle


Posts: 191
Score: 4
Joined: 2/7/2008
Status: offline
Thanks for those tips dm_4ever, I updated the script with those suggestions

Cheers

(in reply to dm_4ever)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Delete Line Function Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts