Help to Italy

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Luca

    #1

    Help to Italy

    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.N avigate("http://www.google.com" )

    doc = Me.AxWebBrowser 1.Document 'Get htmldocument

    Dim ricerca As mshtml.HTMLInpu tTextElement =
    doc.getElements ByName("q").ite m(, 0) 'get inputbox ref
    ricerca.value = "Italy" 'Input value
    Dim submitButton As mshtml.HTMLInpu tButtonElement =
    doc.getElements ByName("btng"). item(, 0)
    submitButton.cl ick() 'click the button

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

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

  • Terry Burns

    #2
    Re: Help to Italy

    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.getElements ByName("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




    "Luca" <visit@tin.it > wrote in message
    news:1139763295 .711051.263190@ g44g2000cwa.goo glegroups.com.. .[color=blue]
    > 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.N avigate("http://www.google.com" )
    >
    > doc = Me.AxWebBrowser 1.Document 'Get htmldocument
    >
    > Dim ricerca As mshtml.HTMLInpu tTextElement =
    > doc.getElements ByName("q").ite m(, 0) 'get inputbox ref
    > ricerca.value = "Italy" 'Input value
    > Dim submitButton As mshtml.HTMLInpu tButtonElement =
    > doc.getElements ByName("btng"). item(, 0)
    > submitButton.cl ick() 'click the button
    >
    > I get this error on the last line: An unhandled exception of type
    > 'System.NullRef erenceException ' occurred in WindowsApplicat ion1.exe
    > Additional information: Object reference not set to an instance of an
    > object
    >
    > Is there anyone who can help me?
    > Thanks in advance.
    > Luca
    >[/color]


    Comment

    • Luca

      #3
      Re: Help to Italy

      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

      Comment

      • Terry Burns

        #4
        Re: Help to Italy

        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


        "Luca" <visit@tin.it > wrote in message
        news:1139782264 .155595.174790@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > 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
        >[/color]


        Comment

        • Luca

          #5
          Re: Help to Italy

          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.

          Comment

          Working...