string.ReadLine

G

Guest

hey all,
i'm trying to read a text document line by line into a stringbuilder and an
issue i'm running into is this:
do while streamReader.ReadLine
stringBuilder.Append("my string" & string.ReadLine)
is showing up like this:
"my string"
value

instead of
"my string" value

how do i keep the value on the same line as my string?

thanks,
rodchar
 
S

Siva M

Remove the new-line char before appending.

hey all,
i'm trying to read a text document line by line into a stringbuilder and an
issue i'm running into is this:
do while streamReader.ReadLine
stringBuilder.Append("my string" & string.ReadLine)
is showing up like this:
"my string"
value

instead of
"my string" value

how do i keep the value on the same line as my string?

thanks,
rodchar
 
G

Guest

Howdy,


Dim reader As StreamReader = File.OpenText(pathToMyFile)
Dim line As String = reader.ReadLine()
Dim builder As New System.Text.StringBuilder()


Do Until line Is Nothing

builder.Append("my value")
builder.Append(line)

line = reader.ReadLine()

Loop


TextBox1.Text = builder.ToString()
 
S

Siva M

Sorry, ignore my reply.

Remove the new-line char before appending.

hey all,
i'm trying to read a text document line by line into a stringbuilder and an
issue i'm running into is this:
do while streamReader.ReadLine
stringBuilder.Append("my string" & string.ReadLine)
is showing up like this:
"my string"
value

instead of
"my string" value

how do i keep the value on the same line as my string?

thanks,
rodchar
 
G

Guest

thanks for the help. rod.

Milosz Skalecki said:
Howdy,


Dim reader As StreamReader = File.OpenText(pathToMyFile)
Dim line As String = reader.ReadLine()
Dim builder As New System.Text.StringBuilder()


Do Until line Is Nothing

builder.Append("my value")
builder.Append(line)

line = reader.ReadLine()

Loop


TextBox1.Text = builder.ToString()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top