none
How to navigate line per line on multiline textbox RRS feed

  • Question

  • hello !

    i want to know.....how do i navigate with webbrowser line per line on a multiline textbox ?

    i know this : webbrowser1.navigate(textbox1.text)

    but i dont want to navigate with all the text on textbox, i want to navigate line per line !

    Thanks for the help !

    Thursday, January 23, 2014 6:57 PM

Answers

  • Hi,

     You can try using the Lines property of the textbox like in this example. Each time you press the button it navigates the webbrowser to the url on the next line until it gets to the last line. When the last line is reached it will start at the first line again.

    Public Class Form1
        Dim ln As Integer = 0
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Multiline = True
            TextBox1.ScrollBars = ScrollBars.Both
            TextBox1.WordWrap = False
            WebBrowser1.ScriptErrorsSuppressed = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Lines.Count >= ln Then
                WebBrowser1.Navigate(TextBox1.Lines(ln))
                ln += 1
            Else
                ln = 0 'reset ln to 0 to start back at the first line if the last line was read
            End If
        End Sub
    End Class
    

    • Marked as answer by garocco98 Thursday, January 23, 2014 7:53 PM
    Thursday, January 23, 2014 7:25 PM
  • Hi,

     Sorry about the delay. My internet connection keep blanking out on me. Anyways, you could try it like this. Keeping in mind that the TextBox.Lines property is an array which is 0 indexed. Meaning the first line is actually 0, the second is 1, and so on. I put it in a button click event but you can pretty much put it where you need to.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Multiline = True
            TextBox1.ScrollBars = ScrollBars.Both
            TextBox1.WordWrap = False
            WebBrowser1.ScriptErrorsSuppressed = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Lines.Count > 0 Then WebBrowser1.Navigate(TextBox1.Lines(0))
            If TextBox1.Lines.Count > 1 Then WebBrowser2.Navigate(TextBox1.Lines(1))
            If TextBox1.Lines.Count > 2 Then WebBrowser3.Navigate(TextBox1.Lines(2))
            If TextBox1.Lines.Count > 3 Then WebBrowser4.Navigate(TextBox1.Lines(3))
            If TextBox1.Lines.Count > 4 Then WebBrowser5.Navigate(TextBox1.Lines(4))
            If TextBox1.Lines.Count > 5 Then WebBrowser6.Navigate(TextBox1.Lines(5))
            If TextBox1.Lines.Count > 6 Then WebBrowser7.Navigate(TextBox1.Lines(6))
            If TextBox1.Lines.Count > 7 Then WebBrowser8.Navigate(TextBox1.Lines(7))
            If TextBox1.Lines.Count > 8 Then WebBrowser9.Navigate(TextBox1.Lines(8))
            If TextBox1.Lines.Count > 9 Then WebBrowser10.Navigate(TextBox1.Lines(9))
        End Sub
    End Class

    • Marked as answer by garocco98 Thursday, January 23, 2014 9:58 PM
    Thursday, January 23, 2014 9:31 PM

All replies

  • Hi,

     You can try using the Lines property of the textbox like in this example. Each time you press the button it navigates the webbrowser to the url on the next line until it gets to the last line. When the last line is reached it will start at the first line again.

    Public Class Form1
        Dim ln As Integer = 0
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Multiline = True
            TextBox1.ScrollBars = ScrollBars.Both
            TextBox1.WordWrap = False
            WebBrowser1.ScriptErrorsSuppressed = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Lines.Count >= ln Then
                WebBrowser1.Navigate(TextBox1.Lines(ln))
                ln += 1
            Else
                ln = 0 'reset ln to 0 to start back at the first line if the last line was read
            End If
        End Sub
    End Class
    

    • Marked as answer by garocco98 Thursday, January 23, 2014 7:53 PM
    Thursday, January 23, 2014 7:25 PM
  • Hi, 

    First of all, thanks a lot !!!! it wasn´t exactly what i wanted, but it helped me to do. i was trying to do something like a link checker for multiple links, ( for example, if the link is online label1.backcolor will be green, if the link isn´t online, label1.backcolor will be red. )

    i have already made a "first version" of this app, and you should paste link per link on each textbox, like that :

    webbrowser1.navigate(textbox1.text) 

    webbrowser2.navigate (textbox2.text)

    .

    .

    .

    But it´s really tiring and boring to copy and paste link per link on each textbox.....and now i can do it in just one textbox, and paste all the links at the same time.

    THANKS YOU REALLY HELPED ME !!!!!!!!!!!

    ALL THE BEST !!!!

    Thursday, January 23, 2014 7:53 PM
  • Hi,

     Your Welcome. I guess i misunderstood what you where doing but, if that works for you then that is good.  :)

    Thursday, January 23, 2014 8:00 PM
  • hello again.....

     i am having another trouble, can you help me ?

    i have ten webbrowser, and i want that each line of the textbox navigate the matching webbrowser. Like that

    Webbrowser1 navigate with the link on line 1 of the textbox.

    Webbrowser2 navigate with the link on line 2 of the textbox.

    Webbrowser3 navigate with the link on line 3 of the textbox.

    Know how i do that ?

    i tried to use your code to do this :

    If TextBox1.Lines.Count >= ln Then
                WebBrowser1.Navigate(TextBox1.Lines(ln))
                ln += 1
            Else
                ln = 0 'reset ln to 0 to start back at the first line if the last line was read
            End If
    
            If TextBox1.Lines.Count >= ln Then
                WebBrowser1.Navigate(TextBox1.Lines(ln))
                ln += 2
            Else
                ln = 0 'reset ln to 0 to start back at the first line if the last line was read
            End If
    
            If TextBox1.Lines.Count >= ln Then
                WebBrowser1.Navigate(TextBox1.Lines(ln))
                ln += 3
            Else
                ln = 0 'reset ln to 0 to start back at the first line if the last line was read
            End If

    but it fails, give this error """ Index was outside the bounds of the array.""""

    Can you help me again ?

    Thursday, January 23, 2014 8:23 PM
  • Hi,

     Sorry about the delay. My internet connection keep blanking out on me. Anyways, you could try it like this. Keeping in mind that the TextBox.Lines property is an array which is 0 indexed. Meaning the first line is actually 0, the second is 1, and so on. I put it in a button click event but you can pretty much put it where you need to.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Multiline = True
            TextBox1.ScrollBars = ScrollBars.Both
            TextBox1.WordWrap = False
            WebBrowser1.ScriptErrorsSuppressed = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Lines.Count > 0 Then WebBrowser1.Navigate(TextBox1.Lines(0))
            If TextBox1.Lines.Count > 1 Then WebBrowser2.Navigate(TextBox1.Lines(1))
            If TextBox1.Lines.Count > 2 Then WebBrowser3.Navigate(TextBox1.Lines(2))
            If TextBox1.Lines.Count > 3 Then WebBrowser4.Navigate(TextBox1.Lines(3))
            If TextBox1.Lines.Count > 4 Then WebBrowser5.Navigate(TextBox1.Lines(4))
            If TextBox1.Lines.Count > 5 Then WebBrowser6.Navigate(TextBox1.Lines(5))
            If TextBox1.Lines.Count > 6 Then WebBrowser7.Navigate(TextBox1.Lines(6))
            If TextBox1.Lines.Count > 7 Then WebBrowser8.Navigate(TextBox1.Lines(7))
            If TextBox1.Lines.Count > 8 Then WebBrowser9.Navigate(TextBox1.Lines(8))
            If TextBox1.Lines.Count > 9 Then WebBrowser10.Navigate(TextBox1.Lines(9))
        End Sub
    End Class

    • Marked as answer by garocco98 Thursday, January 23, 2014 9:58 PM
    Thursday, January 23, 2014 9:31 PM
  • It works ! 

    thanks again ! now i can finish it !

    Dont worry about the the delay and internet, it's okay. The important is that you helped me, thanks again !


    Thursday, January 23, 2014 9:58 PM
  • It works ! 

    thanks again ! now i can finish it !

    Dont worry about the the delay and internet, it's okay. The important is that you helped me, thanks again !


     Your Welcome. Glad it helped  :)
    Thursday, January 23, 2014 10:00 PM