Hi Guys,
I'm trying to read a text file, line by line and then use some of the data from these lines as I read them.
I'm OK with opening the file and reading the text in using (tempReadline = objReader.ReadLine() & vbNewLine)
The main problem I have is that the text often has mutiple spaces, or mutiple "-" chars in it. What I'm trying to do is to get a consistent single character throughout, e.g.
to
I have tried using the TRIM function as follows -->
however the result is -->
so it does not TRIM all of the extra spaces within the string.
Ideally I'd like to repalce all mutiple chars with a single char of my choice (space being the default)...
I did also look at the REPLACE function, however do not want to replace ALL the spaces (or selected char) and I started to look at Regualar Expressions --- however could not find anything.
I also did search the forum to see if this had come up.
If someone can help please.
Tkx,
Brian
I'm trying to read a text file, line by line and then use some of the data from these lines as I read them.
I'm OK with opening the file and reading the text in using (tempReadline = objReader.ReadLine() & vbNewLine)
The main problem I have is that the text often has mutiple spaces, or mutiple "-" chars in it. What I'm trying to do is to get a consistent single character throughout, e.g.
VB.NET:
" This is an example of a string "
VB.NET:
"This is an example of a string"
I have tried using the TRIM function as follows -->
Dim charsToTrim() As Char = {"*"c, " "c, "-"c} tempReadline = objReader.ReadLine() & vbNewLine TrimTextLine = tempReadline.Trim(charsToTrim)
however the result is -->
VB.NET:
"This is an example of a string"
so it does not TRIM all of the extra spaces within the string.
Ideally I'd like to repalce all mutiple chars with a single char of my choice (space being the default)...
I did also look at the REPLACE function, however do not want to replace ALL the spaces (or selected char) and I started to look at Regualar Expressions --- however could not find anything.
I also did search the forum to see if this had come up.
If someone can help please.
Tkx,
Brian
Last edited by a moderator: