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.getAttribute(...)
ihe2 = DirectCast(ihe, IHTMLElement2)
ihe2.getElementsByTagName(...)
</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" <cs*****@hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Charles,
Thanks for the reply. I need to use the getElementsByTagName 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" <bl***@nowhere.com> wrote in message
news:OL*************@TK2MSFTNGP15.phx.gbl... 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" <cs*****@hotmail.com> wrote in message
news:uu**************@tk2msftngp13.phx.gbl... 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