Solved

GetElementByID

Posted on 2009-05-17
2
1,961 Views
Last Modified: 2013-11-27
I am making a application in microsoft visual basic 2008 express edition using VB.net as the programming language.

What I want to do is get the contens of a textbox on my webbrowser by using GetElementByID then putting the contens into my RichTextBox1 I'm not sure how I would do this so can you help please.

I think that I need to but the contens to string then do RichTextBox1.Text = stringname


Thanks,
Cyberdemon1337 :D

If you have any diffuculty understanding what I said then just message me and I will try to explain it a bit more :)
0
Comment
Question by:CyberDemon1337
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
CyberLex earned 40 total points
ID: 24407029
cheers
CyberLex
Public Class Form1
 
    'create a webbrowser object
    Dim wb As New WebBrowser
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        'supress javascript errors (just in caste :=)
        wb.ScriptErrorsSuppressed = True
 
        'load the webpage
        wb.Navigate("http://www.echoecho.com/htmlforms11.htm")
 
        'add event handler to documentCompleted sub
        'will be called when html is completely loaded
        'from wb.navigate
        AddHandler wb.DocumentCompleted, AddressOf documentCompleted
 
    End Sub
 
    Public Sub documentCompleted(ByVal sender As Object, ByVal e As System.EventArgs)
 
        'search the dropdownbox with name "mydropdown"
        Dim myid As HtmlElement = wb.Document.GetElementById("mydropdown")
 
        'get the elements of <select> with name "option"
        Dim myelements As HtmlElementCollection = myid.GetElementsByTagName("option")
 
        'itterate through all of those and add to textbox with a linefeed
        For Each ele As HtmlElement In myelements
 
            RichTextBox1.AppendText(ele.InnerText & vbCrLf)
 
        Next
 
    End Sub
 
End Class

Open in new window

0
 

Author Closing Comment

by:CyberDemon1337
ID: 31582395
Very nice and helpful thanks :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question