By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Help to Italy

P: n/a
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

Feb 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"Luca" <vi***@tin.it> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.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

Feb 12 '06 #2

P: n/a
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

Feb 12 '06 #3

P: n/a
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

"Luca" <vi***@tin.it> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.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

Feb 12 '06 #4

P: n/a
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.

Feb 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.