I read some text data from my data base and write it to a text file with this code:
And that works fine and gives me text in the txt file that looks fine to me:
[tt]
ABCD
EFGH
XYZX
....
[/tt]
In another program I want to read this txt file into an ArrayList
When I want to see what's in my ArrayList, I put *** before and after the value, and I keep getting:
[tt]***
ABCD***
***
EFGH***
***
XYZX***
....
[/tt]
I am getting Chr(10) before my value.
I have to strip this character (commented out line in green) and then I get what I want:
[tt]***ABCD***
***EFGH***
***XYZX***
....
[/tt]
Instead of [tt]Environment.NewLine[/tt] I tried vbNewLine and vbCrLf with the same problem.
What am I doing wrong?
How come I need to strip Chr(10) from my values to get what I need?
What do I need to change to NOT get extra Cht(10)?
Have fun.
---- Andy
Code:
Using writer As StreamWriter = New StreamWriter("\\Some_Path\MyFile.txt")
While dtReader.Read = True
writer.WriteLine(dtReader("Some_Field"))
End While
End Using
And that works fine and gives me text in the txt file that looks fine to me:
[tt]
ABCD
EFGH
XYZX
....
[/tt]
In another program I want to read this txt file into an ArrayList
Code:
Private aryLNoGeom As New ArrayList
Private strFNoGeom() As String
...
Dim str As String = My.Computer.FileSystem.ReadAllText(MyFile.txt)
strFNoGeom = str.Split([red]Environment.NewLine[/red])
For z As Integer = 0 To UBound(strFNoGeom)[green]
'aryLNoGeom.Add(Strings.Replace(strFNoGeom(z), Chr(10), ""))[/green]
aryLNoGeom.Add(strFNoGeom(z))
Next
For z As Integer = 0 To aryLNoGeom.Count - 1
Debug.Print("***" & aryLNoGeom(z) & "***")
Next
When I want to see what's in my ArrayList, I put *** before and after the value, and I keep getting:
[tt]***
ABCD***
***
EFGH***
***
XYZX***
....
[/tt]
I am getting Chr(10) before my value.
I have to strip this character (commented out line in green) and then I get what I want:
[tt]***ABCD***
***EFGH***
***XYZX***
....
[/tt]
Instead of [tt]Environment.NewLine[/tt] I tried vbNewLine and vbCrLf with the same problem.
What am I doing wrong?
How come I need to strip Chr(10) from my values to get what I need?
What do I need to change to NOT get extra Cht(10)?
Have fun.
---- Andy