|
-
Jun 28th, 2011, 04:53 AM
#1
Thread Starter
Hyperactive Member
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
-
Jun 28th, 2011, 05:36 AM
#2
Re: Webbrowser
You don't need a name. Just put it in an array or collection and identify it by index.
-
Jun 28th, 2011, 07:26 AM
#3
Thread Starter
Hyperactive Member
Re: Webbrowser
can you help? i have no idea about how dim one. thanks
-
Jun 28th, 2011, 08:19 PM
#4
Thread Starter
Hyperactive Member
Re: Webbrowser
anyone? can i have a code sample plz?
-
Jun 28th, 2011, 08:37 PM
#5
Thread Starter
Hyperactive Member
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?
-
Jun 28th, 2011, 09:04 PM
#6
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.
-
Jun 28th, 2011, 09:09 PM
#7
Thread Starter
Hyperactive Member
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
-
Jun 28th, 2011, 09:20 PM
#8
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.
-
Jun 28th, 2011, 09:35 PM
#9
Thread Starter
Hyperactive Member
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 .
-
Jun 28th, 2011, 09:45 PM
#10
Thread Starter
Hyperactive Member
Re: Webbrowser
If there is no solution , ill just create 10 webbrowser and run with them .
-
Jun 28th, 2011, 11:46 PM
#11
Thread Starter
Hyperactive Member
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 ??
-
Jun 29th, 2011, 12:01 AM
#12
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.
-
Jun 29th, 2011, 12:24 AM
#13
Thread Starter
Hyperactive Member
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?
-
Jun 29th, 2011, 12:33 AM
#14
Thread Starter
Hyperactive Member
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
-
Jun 29th, 2011, 01:10 PM
#15
Thread Starter
Hyperactive Member
-
Jun 29th, 2011, 03:04 PM
#16
New Member
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
-
Jun 29th, 2011, 04:47 PM
#17
Thread Starter
Hyperactive Member
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??
-
Jun 29th, 2011, 07:08 PM
#18
Thread Starter
Hyperactive Member
-
Jul 1st, 2011, 06:46 PM
#19
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|