IHTMLElement Question

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

    #1

    IHTMLElement Question

    Why are there 4 options to choose from and which one is the correct one to
    use?

    IHTMLElement or IHTMLElement2 or IHTMLElement3 or IHTMLElement4

    Thanks,
    Curtis


  • Charles Law

    #2
    Re: IHTMLElement Question

    Hi Curtis

    IHTMLElement is the original interface, but as more functionality was added
    the 2, 3 and 4 interfaces were created. All are valid, so use the one that
    exposes the methods and/or properties that you require.

    HTH

    Charles


    "Curtis" <csch_nu@hotmai l.com> wrote in message
    news:uuf7DuYqFH A.2364@tk2msftn gp13.phx.gbl...[color=blue]
    > Why are there 4 options to choose from and which one is the correct one to
    > use?
    >
    > IHTMLElement or IHTMLElement2 or IHTMLElement3 or IHTMLElement4
    >
    > Thanks,
    > Curtis
    >[/color]


    Comment

    • Curtis

      #3
      Re: IHTMLElement Question

      Charles,

      Thanks for the reply. I need to use the getElementsByTa gName in
      IHTMLElement2 and the getAttribute method in IHTMLElement class. It seems to
      work by just using the IHTMLElement class and using both methods for the
      same element. Will that create any future problems for me?

      Thanks,
      Curtis

      "Charles Law" <blank@nowhere. com> wrote in message
      news:OLMZf0YqFH A.620@TK2MSFTNG P15.phx.gbl...[color=blue]
      > Hi Curtis
      >
      > IHTMLElement is the original interface, but as more functionality was
      > added the 2, 3 and 4 interfaces were created. All are valid, so use the
      > one that exposes the methods and/or properties that you require.
      >
      > HTH
      >
      > Charles
      >
      >
      > "Curtis" <csch_nu@hotmai l.com> wrote in message
      > news:uuf7DuYqFH A.2364@tk2msftn gp13.phx.gbl...[color=green]
      >> Why are there 4 options to choose from and which one is the correct one
      >> to use?
      >>
      >> IHTMLElement or IHTMLElement2 or IHTMLElement3 or IHTMLElement4
      >>
      >> Thanks,
      >> Curtis
      >>[/color]
      >
      >[/color]


      Comment

      • Charles Law

        #4
        Re: IHTMLElement Question

        Hi Curtis

        The fact that you are able to do this implies to me that you have Option
        Strict Off, or at least you have not turned it on. If it were turned on you
        would get a compile time error.

        That is not to say that it will not work that way, however I prefer to use
        something like

        <code>
        Option Strict On

        ....

        Dim ihe As IHTMLElement
        Dim ihe2 As IHTMLElement2

        ' Initialise ihe
        ihe = ...

        ihe.getAttribut e(...)

        ihe2 = DirectCast(ihe, IHTMLElement2)

        ihe2.getElement sByTagName(...)
        </code>

        It's more typing, but it will execute quicker as it avoids late-binding. You
        will also get intelli-sense for the IHTMLElement2 interface, and it avoids
        ugly runtime errors when you mistype a method and the compiler is not
        instructed to check at compile time.

        HTH

        Charles


        "Curtis" <csch_nu@hotmai l.com> wrote in message
        news:eIPmywbqFH A.2696@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Charles,
        >
        > Thanks for the reply. I need to use the getElementsByTa gName in
        > IHTMLElement2 and the getAttribute method in IHTMLElement class. It seems
        > to work by just using the IHTMLElement class and using both methods for
        > the same element. Will that create any future problems for me?
        >
        > Thanks,
        > Curtis
        >
        > "Charles Law" <blank@nowhere. com> wrote in message
        > news:OLMZf0YqFH A.620@TK2MSFTNG P15.phx.gbl...[color=green]
        >> Hi Curtis
        >>
        >> IHTMLElement is the original interface, but as more functionality was
        >> added the 2, 3 and 4 interfaces were created. All are valid, so use the
        >> one that exposes the methods and/or properties that you require.
        >>
        >> HTH
        >>
        >> Charles
        >>
        >>
        >> "Curtis" <csch_nu@hotmai l.com> wrote in message
        >> news:uuf7DuYqFH A.2364@tk2msftn gp13.phx.gbl...[color=darkred]
        >>> Why are there 4 options to choose from and which one is the correct one
        >>> to use?
        >>>
        >>> IHTMLElement or IHTMLElement2 or IHTMLElement3 or IHTMLElement4
        >>>
        >>> Thanks,
        >>> Curtis
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Cor Ligthert [MVP]

          #5
          Re: IHTMLElement Question

          Charles,

          You forget to tell something about the speed differences between the
          interfaces.

          I did not tell it because I had it from you.

          :-)

          Cor


          Comment

          • Charles Law

            #6
            Re: IHTMLElement Question

            Hi Cor

            I didn't mention the speed because the OP was referring to IHTMLElement and
            IHTMLElement2, rather than HTMLElement. Although I haven't explicitly tried
            it, I suspect that the same issue will exist between IHTMLElement and
            HTMLElement as I wrote about HTMLDocument back in September 2003, so I guess
            it is worth adding that interfaces here are quicker than objects.

            Charles


            "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
            news:%23T5hZTtq FHA.2880@TK2MSF TNGP12.phx.gbl. ..[color=blue]
            > Charles,
            >
            > You forget to tell something about the speed differences between the
            > interfaces.
            >
            > I did not tell it because I had it from you.
            >
            > :-)
            >
            > Cor
            >[/color]


            Comment

            Working...