Dim arLines() As String = .Lines '// get all lines into a String.Array.
arLines(2) = "line.3 has been updated" '// update selected line.
.Lines = arLines '// add lines back to TextBox.
When you count lines or anything by using .Count or .Length, it starts at 1 then 2,3,4,etc.
When you use an Index, it starts at 0 Not 1, and it goes as 0,1,2,3,etc.
.this is the reason you might have/will notice the "-1"'s when working with .Items and Indexes.
You should always check if the line you would like to edit is there for you to edit.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
changeLineInCoolTextBox(0, ">>>>>>>>>") '// first line.
changeLineInCoolTextBox(TextBox1.Lines.Length - 1, "<<<<<<<<<") '// last line.
Private Sub changeLineInCoolTextBox(ByVal iCoolLineIndex As Integer, ByVal selContentToReplaceCoolLineWith As String)
If Not iCoolLineIndex > TextBox1.Lines.Length - 1 Then '// check if the line you would like to replace exists in TextBox.
Dim lines() As String = TextBox1.Lines
lines(iCoolLineIndex) = selContentToReplaceCoolLineWith
TextBox1.Text = Join(lines, vbCrLf)
MsgBox("index was outside the bounds of the cool array, since it is greater(in this case) than the TextBox.Lines", MsgBoxStyle.Critical)