Home All Groups Group Topic Archive Search About
Author
12 Feb 2006 5:02 PM
Luca
Hello from Naples Italy, I need help to develop an application that
fill fields automatically in a WEB page and then submit the request. I
really need it for getting automatically rates from low cost airline
but I am testing it with Google. I am writing the following code in
VB.net

AxWebBrowser1.Navigate("http://www.google.com")

        doc = Me.AxWebBrowser1.Document  'Get htmldocument

        Dim ricerca As mshtml.HTMLInputTextElement =
doc.getElementsByName("q").item(, 0)         'get inputbox ref
        ricerca.value = "Italy" 'Input value
               Dim submitButton As mshtml.HTMLInputButtonElement =
doc.getElementsByName("btng").item(, 0)
submitButton.click() 'click the button

I get this error on the last line: An unhandled exception of type
'System.NullReferenceException' occurred in WindowsApplication1.exe
Additional information: Object reference not set to an instance of an
object

Is there anyone who can help me?
Thanks in advance.
Luca

Author
12 Feb 2006 5:21 PM
Terry Burns
This error message means that the object reference is set to Nothing.

So for example if I do this.

Dim  myClassInstance As  MyClassType

then

myClassInstance.MyMethod

I will get the same error because I did not instantiate a new object of Type
MyClassType or set myClassInstance to reference for an existing object of
that type.

Looking at your code

doc.getElementsByName("btng").item(, 0)

You have probably made a mistake with the line here perhaps the name "btng"
is incorrect and it does not return an object.

HTH

--
Terry Burns
http://TrainingOn.net



Show quoteHide quote
"Luca" <vi***@tin.it> wrote in message
news:1139763295.711051.263190@g44g2000cwa.googlegroups.com...
> Hello from Naples Italy, I need help to develop an application that
> fill fields automatically in a WEB page and then submit the request. I
> really need it for getting automatically rates from low cost airline
> but I am testing it with Google. I am writing the following code in
> VB.net
>
> AxWebBrowser1.Navigate("http://www.google.com")
>
>        doc = Me.AxWebBrowser1.Document  'Get htmldocument
>
>        Dim ricerca As mshtml.HTMLInputTextElement =
> doc.getElementsByName("q").item(, 0)         'get inputbox ref
>        ricerca.value = "Italy" 'Input value
>               Dim submitButton As mshtml.HTMLInputButtonElement =
> doc.getElementsByName("btng").item(, 0)
> submitButton.click() 'click the button
>
> I get this error on the last line: An unhandled exception of type
> 'System.NullReferenceException' occurred in WindowsApplication1.exe
> Additional information: Object reference not set to an instance of an
> object
>
> Is there anyone who can help me?
> Thanks in advance.
> Luca
>
Author
12 Feb 2006 10:11 PM
Luca
Thanks Terry but btng is how google calls the button, you can see it in
html page of google so my question is: why my instruction does not
return anything?
Can you help with this
Author
12 Feb 2006 10:55 PM
Terry Burns
Its a bit difficult without actually working on it. Suffice to say that this
is not returning the object and thats where you need to concentrate.

--
Terry Burns
http://TrainingOn.net

Show quoteHide quote
"Luca" <vi***@tin.it> wrote in message
news:1139782264.155595.174790@f14g2000cwb.googlegroups.com...
> Thanks Terry but btng is how google calls the button, you can see it in
> html page of google so my question is: why my instruction does not
> return anything?
> Can you help with this
>
Author
13 Feb 2006 4:04 PM
Luca
Thanks Terry, I really apologize to bother you, I usually work with VB
and I am not very familiar with .net,I am getting crazy with this.
I am looking for a way to fill fields in a WEB page and update in an
Access table the result.
Please give me a line to follow and I will offer you a good pizza when
you come to Naples.