Everyone,
My code is below I am trying to build an app that would feed stock quotes into a textbox on a webpage, submit that page and retrieve the resulting quote. I am coding based upon a tutorial I received from a member here but I can't seem to get the page manipulated. When ever I run I get a NullReferenceException error at the line highlighted. Hopefully someone can help.
Thanks
VB Code:
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load WebBrowser.Navigate("http://moneycentral.msn.com/investor/research/welcome.asp") End Sub Private Function GetCurrentWebDoc() As mshtml.HTMLDocument Try Return DirectCast(WebBrowser.Document, mshtml.HTMLDocument) Catch ex As Exception Return Nothing End Try End Function Private Function GetCurrentWebForm() As mshtml.HTMLFormElement Try If GetCurrentWebDoc.forms.length > 0 Then Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement) Else Return Nothing End If Catch ex As Exception Return Nothing End Try End Function Private Sub SetTextboxText(ByVal Text As String) [COLOR=Red]DirectCast(GetCurrentWebForm.item("Symbol"), mshtml.HTMLInputElement).value = Text[/COLOR] End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SetTextboxText(txtdata.Text) ClickSubmitButton() End Sub Private Sub ClickNormalButton() DirectCast(GetCurrentWebForm.item("q", 0), mshtml.HTMLButtonElement).click() End Sub Private Sub ClickSubmitButton() DirectCast(GetCurrentWebForm.item("go", 0), mshtml.HTMLButtonElement).click() End Sub



Reply With Quote