3 Replies - 4092 Views - Last Post: 26 March 2012 - 04:24 AM Rate Topic: -----

#1 eawedat  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 20-November 11

Question : VB.NET WebBrowser Control Delay

Posted 26 March 2012 - 03:18 AM

hey all,

I have this code in VB.NET :

Having:
1 TextBox
1 Button

with this code:

Public Class Form1
    Dim m As String()
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        m = TextBox1.Text.Split(Environment.NewLine)
        For Each k As String In m
            'MessageBox.Show(k)
            WebBrowser1.Navigate(k)
        Next

    End Sub




input
www.a.com
www.b.com
www.c.com
www.google.com



it navigates only to the last website (www.google.com)
i think that's because the for loop is faster that navigation process

is there any suggestion ?

maybe using threads or sleep helps! but i need someone to help me combining all together.


thanks a lot.

Is This A Good Question/Topic? 0
  • +

Replies To: Question : VB.NET WebBrowser Control Delay

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question : VB.NET WebBrowser Control Delay

Posted 26 March 2012 - 03:56 AM

Have you set your Textbox's Multiline property to True?

The reason for your problem is because you're using only one WebBrowser control. How do you expect it to go to multiple sites in one WebBrowser?
Was This Post Helpful? 0
  • +
  • -

#3 eawedat  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 20-November 11

Re: Question : VB.NET WebBrowser Control Delay

Posted 26 March 2012 - 04:01 AM

yes the Textbox has multiple lines.

I expect webbrowser to navigate to multiple sites by splitting the sites into array..

as you can see here

 m = TextBox1.Text.Split(Environment.NewLine)

    For Each k As String In m
    WebBrowser1.Navigate(k)
    Next

Was This Post Helpful? 0
  • +
  • -

#4 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Question : VB.NET WebBrowser Control Delay

Posted 26 March 2012 - 04:24 AM

It doesn't work that way. No matter how many sites you have, you still have one WebBrowser control to run them. You have to make an array of WebBrowser controls and let each site run in separate browsers.

        Dim m As String()
        Dim w As New WebBrowser()

        m = TextBox1.Text.Split(Environment.NewLine)

        For Each k As String In m
            Controls.Add(w) 'adding each newly created WebBroser control to the form
            w.Navigate(k)
        Next


Since you're adding WebBrowser controls at runtime, you will run into an issue of positioning them in the form. You'll have to think of a way to avoid that.

The best way to accomplish what you're trying to do is to have tabs in one WebBrowser control. Check this tutorial and give it a try.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1