VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,403 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,633 people online right now. Registration is fast and FREE... Join Now!




search and replace in .TXT file

 

search and replace in .TXT file

MoistFist

30 Jun, 2009 - 09:28 AM
Post #1

D.I.C Head
**

Joined: 2 Jun, 2009
Posts: 76


My Contributions





Hey , i am having trouble on this code, A freind gave to me as a sample to edit but i am not sure how i would add, my stuff. What i need to to is just read a txt file and replace some characters like
Replace("1", ",")
any ideas on how to manipulate that in there?


CODE
txtInputIPlist.Text = "C:\Documents and Settings\bcunnin6\Desktop\EPR\clean.txt"
        Dim dTelip As Double
        Dim stext As String
        Dim sFile As String

        For Each sFile In ofdIPlist.FileNames
            Dim slijn As String
            FileOpen(1, sFile, OpenMode.Input)
            Do Until EOF(1)
                slijn = LineInput(1)
                If slijn = "string 1" Then
                    stext = stext & "altered text" & vbCrLf
                Else : stext = stext & slijn & vbCrLf
                End If
            Loop
            FileClose(1)
        Next
        txtInputIPlist.Text = txtInputIPlist.Text & stext
    End Sub


User is offlineProfile CardPM
+Quote Post


NoBrain

RE: Search And Replace In .TXT File

30 Jun, 2009 - 09:55 AM
Post #2

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,152



Thanked: 33 times
Dream Kudos: 125
My Contributions
what errors you got ?
User is offlineProfile CardPM
+Quote Post

NoBrain

RE: Search And Replace In .TXT File

30 Jun, 2009 - 10:01 AM
Post #3

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,152



Thanked: 33 times
Dream Kudos: 125
My Contributions
oh biggrin.gif yea
User is offlineProfile CardPM
+Quote Post

NoBrain

RE: Search And Replace In .TXT File

30 Jun, 2009 - 10:09 AM
Post #4

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,152



Thanked: 33 times
Dream Kudos: 125
My Contributions
now
CODE

txtInputIPlist.Text = "C:\Documents and Settings\bcunnin6\Desktop\EPR\clean.txt"
        Dim dTelip As Double
        Dim stext As String
        Dim sFile As String
        Dim replaceStr as String

        For Each sFile In ofdIPlist.FileNames
            Dim slijn As String
            FileOpen(1, sFile, OpenMode.Input)
            Do Until EOF(1)
                slijn = LineInput(1)
                replaceStr=Replace(slijn, "1", ",")
                sText=sFile&replaceStr      
            Loop
            FileClose(1)
        Next
        txtInputIPlist.Text = txtInputIPlist.Text & stext
    End Sub



this should work

edit: i forget to place slijn in replace function sorry smile.gif and sText is the text for input after replace right

This post has been edited by NoBrain: 30 Jun, 2009 - 10:12 AM
User is offlineProfile CardPM
+Quote Post

MoistFist

RE: Search And Replace In .TXT File

30 Jun, 2009 - 12:14 PM
Post #5

D.I.C Head
**

Joined: 2 Jun, 2009
Posts: 76


My Contributions
hey mans thanks again, great job , i see where you can edit it and movie it around ....sweet
User is offlineProfile CardPM
+Quote Post

NoBrain

RE: Search And Replace In .TXT File

30 Jun, 2009 - 10:16 PM
Post #6

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,152



Thanked: 33 times
Dream Kudos: 125
My Contributions
no problem dude smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:30PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month