?
Solved

Delete a text from a .txt file using vb6.0

Posted on 2010-01-12
5
Medium Priority
?
354 Views
Last Modified: 2012-05-08
I need to search for a string in the .txt file and then delete it... any easy way to do this?

thanks
0
Comment
Question by:Carol2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Accepted Solution

by:
Rimvis earned 2000 total points
ID: 26294006
Hello Carol2009,

Check this:

Edit and manipulate text files
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6454&lngWId=4

Regards,

Rimvis
0
 

Author Comment

by:Carol2009
ID: 26294121
That was for ASP (Active Server Pages), VbScript (browser/client side)  .. i am interst only on visual basic v6.0

Thanks
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 26294186
Hello Carol2009,

1. A specific string, or a string meeting a particular pattern/criteria?
2. All instances of the string, or just the first?
3. Is the text file large or small?

Regards,

Patrick
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 26294191
The code for VB 6.0 is neatly identical. Just add type declarations like his:

Dim objFSO as FileSystemObject

0
 
LVL 14

Expert Comment

by:VBClassicGuy
ID: 26294285
Something like (excuse my use of Implicit variable declaration):
s% = Freefile
t% = Freefile
Open "C:\MyFile.txt" for Input As #s%   'source (original) file
Open "C:\MyFilteredFile.txt" For Output As #t%   'target (with string deleted) file
While Not EOF(s%)
   Line Input #s%, txt$
   Replace(txt$, "Unwanted string", "")
   If Len(txt$) Then Print #t%, txt$
Wend
Close
Kill "C:\MyFile.txt"
Name "C:\MyFilteredFile.txt" As "C:\MyFile.txt"
   
 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question