view each line of RichTextBox in TextBox1 one by one if second line appears to TextBox1 the First line will disappear

48 views Asked by At

i want to display the first line from the richtextbox1 to textbox1 after 5 sec textbox1 will be clear and second line from richtextbox1 show to textbox1

I WANT TO SHOW THE OUTPUT LIKE

green
...after 5 sec   //green will be cleared from Textbox1 and write Yellow
yellow
...after 5 sec   //Yellow will be cleared from Textbox1 and write blue
blue
...after 5 sec   //blue will be cleared from Textbox1 and write red
red

WHAT CAN I DO TO GET THE OUTPUT LIKE THIS..

Thanks in Advance

Actually i tried it but it shows every line from the RichTextbox

i need first line from richtextbox to Textbox1 for 5 seconds thereafter it will disappear the second line will appear on TextBox1

Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick

   For Each strLine As String In RichTextBox2.Text.Split()

       txt_myip.Text = strLine.Remove(0, 1)

   Next

End Sub

I WANT TO SHOW THE OUTPUT in the TextBox1 be like

green
...after 5 sec   //green will be cleared from Textbox1 and write Yellow
yellow
...after 5 sec   //Yellow will be cleared from Textbox1 and write blue
blue
...after 5 sec   //blue will be cleared from Textbox1 and write red
red

WHAT CAN I DO TO GET THE OUTPUT LIKE THIS..

Thanks in Advance

1

There are 1 answers

2
preciousbetine On BEST ANSWER

You should use a timer, Set the Interval to 5000 milliseconds which is 5 seconds and enter this code under the Timer_Tick event

'Declare a variable for storing the current index
Dim index As Integer = 0
Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick
    If (Not index >= RichTextBox2.Lines.Length- 1) Then
        txt_myip.Text = RichTextBox2.Lines(index)
        index += 1
    Else 
        index = 0
        Timer1.Stop()
    End If
End Sub