Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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







  #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
  #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]

  #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


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





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