I have a AXI camera that count the number of people entered the building and show the result on web page with video. The webpages update the count every time it detect a passing person. I believe the page has 2 iframes. Im trying to insert the value of the elementID ("count-in") which is the count result into a textbox after the webbrowserfully loaded. the code below gives me nothing. but if I inserted a button and click on it right after the page loaded, I got the count no problem! here is my code that doesn
t work
I have tried this one
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim webBrowserX As New WebBrowser()
' Add an event handler that prints the document after it loads.
AddHandler webBrowserX.DocumentCompleted, New _
WebBrowserDocumentCompletedEventHandler(AddressOf showMe)
' Set the Url property to load the document.
webBrowserX.Url = New Uri("http://xx.xx.xx.104/people-counter/lite/count.html")
End Sub
Private Sub showMe(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs)
Dim webBrowserX As WebBrowser = CType(sender, WebBrowser)
' now that it is fully loaded.
' webBrowser get the value of the elementID ("count-in")
Dim tableElem As HtmlElement = webBrowserX.Document.GetElementById("count-in")
TextBox1.Text = TextBox1.Text & tableElem.InnerText
End Sub
I have also tried this one,
Private Property pageready As Boolean = False
#Region "Page Loading Functions"
Private Sub WaitForPageLoad()
AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
While Not pageready
Application.DoEvents()
End While
pageready = False
End Sub
Private Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
()
End If
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.WebBrowser1.Navigate("http://xx.xx.xxx.104/people-counter/lite/count.html")
Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)_
Handles WebBrowser1.DocumentCompleted
WaitForPageLoad()
Dim tableElem As HtmlElement = webBrowserX.Document.GetElementById("count-in")
TextBox1.Text = TextBox1.Text & tableElem.InnerText