Hi,

I've been trying to get this working:

VB Code:
  1. Dim iFreeFile1 As Integer, iFreeFile2 As Integer, varData As String, s As String
  2.  
  3. iFreeFile1 = FreeFile
  4. Open App.Path & "\_SettingsDump.dat" For Input As #iFreeFile1
  5. iFreeFile2 = FreeFile
  6. Open sFile For Output As #iFreeFile2
  7. Do While Not EOF(iFreeFile1)
  8.     Line Input #iFreeFile1, varData
  9.     s = varData ' I'll add the replace later
  10.     Print #iFreeFile2, s
  11. Loop
  12. Close #iFreeFile2
  13. Close #iFreeFile1

I want to open a file, replace all instances of a string with another, and save it to another file. I wrote the above code, but the resultant file was just full of rubbish (loads of those square character things). So I took the replace function out and it still produces the same thing.

If I replace the Print #iFreeFile2, s line with Print #iFreeFile2, "a" & s then it works fine, only has the "a" at the start of each line.

I cant see why this shouldnt work, and why adding a character for the Print function suddenly makes it work. What am I doing wrong?