Hi, I'm trying to write a piece of code that will look for text thats inputted in my FindString text box in my Source text file and replace it with text in another text box and write it to my target file. How do I go about doing this. I've got this far and now I'm stuck. I know how to copy from one file to another but how do I find and replace.

Thanks

Vaastav

Private Sub cmdReplace_Click()
Dim sdata As String
Dim FindString As String
Dim ReplaceWith As String


FindString = txtFindString.Text
ReplaceWith = txtReplaceWith.Text

Open "c:\Source.txt" For Input As #1
Open "c:\Target.txt" For Output As #2

While Not EOF(1)
Line Input #1, sdata
Wend

Print #2, sdata

Close #1
Close #2
End Sub