Refering to the discussion until now I would suggest the Following :
- with Loading your Form (for example) you load the Data of your Textfile into an Array (like allready posted from you).
Also assign the 1st Array-Element to your Textbox
Build an Index-Variable (Integer) which points to the line which is allready to be seen
- now hook the KeyUp-Event from the Textbox to a method where you decrease the Index-Variable (and check it against the Array-Bounds).
Assign the Array-Element which is indexed by this Variable to your Textbox
- now hook the KeyDown-Event from the Textbox to a method where you increase the Index-Variable (and check it against the Array-Bounds).
Assign the Array-Element which is indexed by this Variable to your Textbox
Dim ReadSpciFile As array
Dim Index as integer = 0
Private Sub Form1_Load (sender As Object, e As EventArgs) Handles MyBase.Load
Dim line As String
ReadSpciFile = File.ReadAllLines("C:\Users\OM\Desktop\1 (3).txt")
line = ReadSpciFile(0)
RichTextBox1.Text = line
End Sub
private sub DecreaseLine (sender As Object, e As EventArgs) Handles RichTextBox1.KeyUp
Index -= 1
if Index < 0 then Index = 0
line = ReadSpciFile(Index)
RichTextBox1.Text = line
end sub
private sub IncreaseLine (sender As Object, e As EventArgs) Handles RichTextBox1.KeyDown
Index += 1
if Index >= ReadSpciFile.length then Index = ReadSpciFile.length
line = ReadSpciFile(Index)
RichTextBox1.Text = line
end sub
Extended suggestion :
Dim ReadSpciFile As array
Dim Index1 as integer = 0
Dim Index2 as integer = 0
Private Sub Form1_Load (sender As Object, e As EventArgs) Handles MyBase.Load
Dim line As String
ReadSpciFile = File.ReadAllLines("C:\Users\OM\Desktop\1 (3).txt")
line = ReadSpciFile(0)
RichTextBox1.Text = line
End Sub
private sub DecreaseLine1 (sender As Object, e As EventArgs) Handles RichTextBox1.KeyUp
Index1 -= 1
if Index1 < 0 then Index1 = 0
line = ReadSpciFile(Index1)
RichTextBox1.Text = line
end sub
private sub IncreaseLine1 (sender As Object, e As EventArgs) Handles RichTextBox1.KeyDown
Index1 += 1
if Index1 >= ReadSpciFile.length then Index1 = ReadSpciFile.length
line = ReadSpciFile(Index1)
RichTextBox1.Text = line
end sub
private sub DecreaseLine2 (sender As Object, e As EventArgs) Handles RichTextBox2.KeyUp
Index2 -= 1
if Index2 < 0 then Index2 = 0
line = ReadSpciFile(Index2)
RichTextBox2.Text = line
end sub
private sub IncreaseLine2 (sender As Object, e As EventArgs) Handles RichTextBox2.KeyDown
Index2 += 1
if Index2 >= ReadSpciFile.length then Index2 = ReadSpciFile.length
line = ReadSpciFile(Index2)
RichTextBox2.Text = line
end sub