Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


What I have tried:

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
Posted
Updated 22-Jan-19 0:27am

That isn't the way timers work: each time you get a Tick event, you take a line from the RichTextBox and display it in your textbox, then set up conditions for the next Tick - normally by using a class level variable which holds the "next line number" to display.

Using a loop in th Tick handler doesn't do that, if always puts the content from the last line in the text box!

Get rid of the loop, and use a class level Integer as an index into the RichTextBox lines.
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900