How do i get this Text from HTML to TextBox?

TastyTeo

Member
Joined
May 31, 2011
Messages
15
Programming Experience
1-3
I learned to do this with Value's and Input Boxes, but this one is more difficult.

Let's say i have webbrowser1 in my project where the url is on a site which has html like this
VB.NET:
<form id="edit_form_user_friends" name="edit_form_user_friends">
<div class="box-title title-text-color">Friends (<span name="channel-box-item-count">2183</span>)
</div>
</form>

I Want when i press a button to execute a code which will look something like this
TextBox2.Text = WebBrowser1.Document.GetElementById("channel-box-item-count").InnerText

I WANT THIS CODE TO GET THE NUMBER 2183 INTO THE TEXTBOX
So what do i make wrong here?
 
TextBox1.Text = WebBrowser1.Document.All.GetElementsByName("thename")(0).InnerText

Code example gets InnerText of first item from array of all matching elements by name property.
 
...Duh... IT might work but the page has other tags with the same name and it makes the first one if i change this (0) to (1) it changes which one but it is not what i want, any other way?
 
The only option is to use your knowledge of the document element tree to positively identify the correct element. Try to narrow it down, for example by identifying some element, then do .All.GetElementsByName from that. Your form tag for example has an id, so that should be unique, and perhaps there is only one element by the target name in that tree.
 
...Duh... IT might work but the page has other tags with the same name and it makes the first one if i change this (0) to (1) it changes which one but it is not what i want, any other way?
Actually using my knowledge, 5 minutes before you post this, i thought of something which will work, and thanks to my mind, :p although you guys are very helpful on this site THUMBS UP!
 
With this useful post, and of course some mind, i created what i wanted
YouTube Account Information!!!
It gets
Subscribers Count, Friends Count, Subscriptions Count, Channel Views, and Total Upload Views for any youtube channel you want
 
Last edited by a moderator:
Back
Top