Help to Italy

L

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
 
T

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
 
L

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
 
T

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.
 
L

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top