Thom,
What you are doing is storing different values one after another to the
default or first line of the textbox. Naturally the last line stored would
be the one remaining at the end. There are several ways to do what you want,
but I think the one which you will be able to use right away is this one.
Declare a counter and increase it in your loop and use the counter to access
the "Lines" property of the textbox. Also there are better ways to determine
that you have read a line and better ways to detect end of file, but I won't
go into them.
Like so...
Dim strText1 As String
If strTextFileName1 <> "" Then
Label1.Text = strTextFileName1
objTextRead1 = System.IO.File.OpenText(strTextFileName1)
Me.LeftTextbox.Text = strTextFileName1
Dim ACounter as integer = 0
Do Until objTextRead1.Peek = -1 'Check out the while loop and the .Read
property
strText1 = objTextRead1.ReadLine()
Me.LeftTextbox.Lines(ACounter) = strText1
ACounter = ACounter + 1
Loop
objTextRead1.Close()
End If
"Thom" <la*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
I'm a real newbie so I apologize for the easy question. I have academic
version of vb.net 2003.
I am trying to write a multiline textbox with data from a text file.
Properties for the textbox are multiline = true, scrollbars = both,
wordwrap = false.
I actually have two textboxes side by sied for different files and I am
using a splitter.
Here is code for reading from one file to populate the text box. I always
end up with the last line of the file.
'open the first file and display
Dim strText1 As String
If strTextFileName1 <> "" Then
Label1.Text = strTextFileName1
objTextRead1 = System.IO.File.OpenText(strTextFileName1)
Me.LeftTextbox.Text = strTextFileName1
Do Until objTextRead1.Peek = -1
strText1 = objTextRead1.ReadLine()
Me.LeftTextbox.Text = strText1
Loop
objTextRead1.Close()
End If
Any help is appreciated. Thank you. Thom