Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2006, 09:34 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default File handling

Hi All,

Someone help me how to create a txt file using another txt file by eliminating certain information from the source txt file.

Ex A.txt contains the following info
01aaaabbbbcc
04cccccddddeee
01aaaabbbccccc
04cccccddddeee

i need to create file b.txt eliminating the "eee" from the second line i.e 04,we can't say the 04 record will come always at 2nd line but we have the constant value "04" in front of the line.

O/P sample file
01aaaabbbbcc
04cccccdddd
01aaaabbbccccc
04cccccdddd







Reply With Quote
  #2 (permalink)  
Old June 6th, 2006, 10:26 PM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Vijay

check this link
http://www.geocities.com/raghavendra..._text_file.zip

It gives the output as you need. But I am still not sure on what exactly
you are searching for.

Hope this helps.


With Regards,
Raghavendra Mudugal
Reply With Quote
  #3 (permalink)  
Old June 7th, 2006, 01:10 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Raghav,

This code working fine but what i want is
need to eliminate the last 3 chars from the line with prefix "04"
we can't say it will be always like "eee" and we shouldn't disturb the rest of the lines i.e before and after "04" line.

Thanks
Vijay


check this link
http://www.geocities.com/raghavendra..._text_file.zip

It gives the output as you need. But I am still not sure on what exactly
you are searching for.

Hope this helps.


With Regards,
Raghavendra Mudugal
[/quote]

Reply With Quote
  #4 (permalink)  
Old June 7th, 2006, 01:30 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

okay GOTCHA !!!

check this new line of code

Private Sub Command1_Click()
Dim fso As FileSystemObject
Dim tsA As TextStream
Dim tsB As TextStream

Set fso = New FileSystemObject
Set tsA = fso.OpenTextFile(App.Path & "\a.txt", ForReading)
Set tsB = fso.OpenTextFile(App.Path & "\b.txt", ForWriting, True)

While Not tsA.AtEndOfStream
    s = tsA.ReadLine
    Rem NEW CODE
    If Mid$(s, 1, 2) = "04" Then
        Rem OLD CODE s1 = Replace(s, "eee", "")
        s2 = Left(s, Len(s) - 3)
        tsB.WriteLine (s2)
    Else
        tsB.WriteLine (s)
    End If
Wend

tsA.Close
tsB.Close
Set fso = Nothing

MsgBox "Done"
End Sub

I guess, this code make some sense to your requirement?

hope this helps.


With Regards,
Raghavendra Mudugal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
here is my code c++ file handling amahja56 C++ Programming 2 November 23rd, 2007 07:25 AM
File strorage handling using JSP draggy Pro JSP 4 July 30th, 2006 12:44 PM
FILE HANDLING yojeiram_n1 C++ Programming 2 March 13th, 2006 02:57 PM
c++ file handling. amahja56 C++ Programming 2 March 23rd, 2005 07:13 PM
FILE HANDLING sanchita ADO.NET 8 November 8th, 2004 12:34 AM



All times are GMT -4. The time now is 05:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.