Results 1 to 19 of 19

Thread: Webbrowser

  1. #1

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Exclamation Webbrowser

    i want to know how i can Dim a webbrowser. And give it a random name that ill be able to call it . Ex :

    label1.text +=1
    dim web as new webbrowser
    web.name = label1.text
    richtextbox1.text = label1.text & vbnewline 'here i stock up all webbrowser name


    thanks for help

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Webbrowser

    You don't need a name. Just put it in an array or collection and identify it by index.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    can you help? i have no idea about how dim one. thanks

  4. #4

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    anyone? can i have a code sample plz?

  5. #5

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    Maybe you didnt understood what I want to do . What I want is naviguate through a webbrowser and download something with it. Then at sametime download an other thing. That's why I need to "create" them with random name . Can you please help me?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Webbrowser

    There's still nothing in there that suggests that you need any name, random or not. In fact, if want you want is to download files or data then you don't even need a WebBrowser. It would be more appropriate to use WebClient objects to download. You can create as many as you like and perform one download with each. You would most like call an asynchronous method, e.g. DownloadFileAsync, and then use one method to handle the appropriate event, e.g. DownloadFileCompleted, of all WebClients. The 'sender' parameter will be a reference to the WebClient itself, so you can easily identify which download has completed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    I know that but in my project , The webbrowser need to naviguate to get an url(which is random) then I retreive it to a textbox and use downloadAsSync to download it. But i need to "create" more then one browser if the user want to download more than one at the sametime . Thanks for reply

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Webbrowser

    There is still nothing in there that suggests the need for a WebBrowser. Maybe if you were to provide a full and clear explanation of exactly what you're doing then we could suggest the best way to do it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    Okay there we go . My code :


    Dim PageElement5 As HtmlElementCollection = WebBrowser2.Document.GetElementsByTagName("a")
    For Each CurElement5 As HtmlElement In PageElement5
    If (CurElement5.InnerText = "click the direct link") Then
    ListView1.Items(0).SubItems(2).Text = "Download starting ..."
    dw.Text = TextBox2.Text & "\" & ListView1.Items(0).SubItems(0).Text & ".mp3"
    awa.Text = CurElement5.GetAttribute("href")
    awa.Text = awa.Text.Replace(ControlChars.Quote, "")
    awa.Text = awa.Text
    If awa.Text = "" Then
    Else
    WebBrowser2.Navigate("www.flvto.com")

    Timer6.Start()

    End If
    Timer6.Start()
    End If

    Next

    Try
    client.DownloadFileAsync(New Uri(awa.Text), dw.Text)
    Catch ex As Exception
    MsgBox(ErrorToString, MsgBoxStyle.Critical)

    End Try
    Timer6.Stop()
    Timer5.Stop()

    So there is the problem , the webbrowser need to navigate though a server that convert a file . But during this time , it is busy and i cant interrupt it . Once the conversion is done , I use webclient to download the file. But i want to allow the user to download more than one at the sametime. The reason why I need more than one webbrowser . Thats why i want to "create" new ones with dim and list them. Or if there is an other solution to my problem , I'm open to it . Thanks for reply .

  10. #10

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    If there is no solution , ill just create 10 webbrowser and run with them .

  11. #11

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    I found a way by creating like if it was a tabbed webbrowser :


    Dim waa As New WebBrowser
    waa.Name = "waa"
    waa.Dock = DockStyle.Fill
    TabControl2.TabPages.Add(int)
    TabControl2.SelectedTab.Controls.Add(waa)
    TabControl2.SelectTab(int)
    AddHandler waa.DocumentCompleted, AddressOf Done
    int = int + 1

    And I use this code to make events :


    CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Document.GetElementById("link_url").SetAttribute("value", ListBox2.SelectedItem)

    Now the problem is : when i click again on button to add new tab , and the web1 is still doing stuff. It doesnt work . There is an error in CType code . I guess its because it cant control both at same time . IS there a way to do this ??

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Webbrowser

    Don't use this:
    Code:
    CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser)
    Use this:
    Code:
    CType(sender, WebBrowser)
    The 'sender' is the object that raised the event, so it's the WebBrowser whose document has just completed. Like I said, you don't need names at all.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    Doesnt work it say error .

    I use a button to start . It say it's not the same type. Im still getting errors

    I dont know why 2 webbrowser cant do actions at the sametime , Any other suggestions?

  14. #14

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    To help , When i click button1 . it start to get information from webpages with:
    CType(TabControl2.SelectedTab.Controls.Item(0), WebBrowser).Document.GetElementsByTagName("SPAN")

    This take like over a mins sometime , gathering stuff, and at the sametime time , (that i want) if the user click again the button1 , I want it to redo the sames actions without interupt the current ones. If you want i can send more codes . Thanks for help

  15. #15

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    anyone?

  16. #16
    New Member
    Join Date
    Jun 2011
    Posts
    10

    Re: Webbrowser

    When you Declare 'Dim' waa as a 'New' 'WebBrowser' its name is waa
    if you need 10 WebBrowsers Declare them all at once and you can use them at the same time...

    Code:
            Dim Waa As New WebBrowser
            Dim Ele As New HtmlElement
            Waa.Navigate("http://www.yahoo.com")
            Ele = Waa.Document.GetElementById("id-name")
            Me.RichTextBox1.Text = Waa.DocumentText

  17. #17

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    ok hmm but before rescript , ill ask you something , Does this code work for exemple I add it to a button. the ELE gather info (it takes 2 mins) and for exemple i reclick again button . Does the ele will stop working and restart??

  18. #18

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    anyone??

  19. #19

    Thread Starter
    Hyperactive Member ibennz's Avatar
    Join Date
    Aug 2010
    Posts
    282

    Re: Webbrowser

    -bump-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width