Sling_Blade
asked on
Replacing Space with VBCrLf in Text File
I have a large text file of words; each of the words is seperated by one empty space.
What I need to do is to replace the space that seperate the words with the new line character, vbcrlf, so that each word is on its own line.
I have create a filestream object and populated it with the contents of the file.
How can I interate through the filestream object and substitue vbcrlf for each space?
<code>
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\WordLis t.txt")
</code>
What I need to do is to replace the space that seperate the words with the new line character, vbcrlf, so that each word is on its own line.
I have create a filestream object and populated it with the contents of the file.
How can I interate through the filestream object and substitue vbcrlf for each space?
<code>
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\WordLis
</code>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Opps, I tabbed to the submit button by mistake, don't be confused by the code, here is what I meant.
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\WordLis t.txt")
Dim result As String = oRead.ReadToEnd
result.Replace("\s+", ControlChars.CrLf)
Dim oWrite As System.IO.StreamWriter
oWrite = New StreamWriter("C:\NewWordLi st.txt")
oWrite.Write(strData)
oWrite.Close
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\WordLis
Dim result As String = oRead.ReadToEnd
result.Replace("\s+", ControlChars.CrLf)
Dim oWrite As System.IO.StreamWriter
oWrite = New StreamWriter("C:\NewWordLi
oWrite.Write(strData)
oWrite.Close
ASKER
Of course it works anyway!!
Thanks Heaps.
Thanks Heaps.
ASKER
Here is what I have so far
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText("C:\WordLis
Dim result As String = oRead.ReadToEnd
result.Replace("\s+", ControlChars.CrLf)
Dim oWrite As System.IO.StreamWriter
oRead = New StreamWriter("C:\NewWordLi
oRead.Write(strData)
oRead.Close
However the output is exactly the same as the WordList.txt document.