Board index » Visual Studio » Replace , with ~ in a file
|
Wylbur
|
|
Wylbur
|
Replace , with ~ in a file
Visual Studio44
I have a file (mine.ini) where I need to replace every "," with a "~". How do this? Thanks - |
| Jeff
Registered User |
Fri Jul 21 11:09:04 CDT 2006
Re:Replace , with ~ in a file
"gonzosez" <adf>wrote in message
QuoteI have a file (mine.ini) where I need to replace every "," with a "~". Replace() function. - |
| Rick
Registered User |
Fri Jul 21 11:22:26 CDT 2006
Re:Replace , with ~ in a fileQuoteI have a file (mine.ini) where I need to replace every "," with a "~". Dim TotalFile As String ' Let VB generate the file channel number FileNum = FreeFile ' Reads the whole file into memory all at once Open "c:\path\to\mine.ini" For Binary As #FileNum TotalFile = Space(LOF(FileNum)) Get #FileNum, , TotalFile Close #FileNum ' Do the replacement TotalFile = Replace$(TotalFile, ",", "~") ' Let VB generate the file channel number FileNum = FreeFile ' Save the contents of the TotalFile variable back out Open "c:\path\to\mine.ini" For Output As #FileNum Print #FileNum, TotalFile Close #FileNum Rick - |
