Problem using component AxSHDocVw.AxWebBrowser.??

  • Thread starter Thread starter jokolee
  • Start date Start date
J

jokolee

i was using component AxSHDocVw.AxWebBrowser,,but i rather confuces
because when i write
AxWebBrowser1.Document. the next option is Gettype function,,,nothing
else......
But when i write AxWebBrowser1.Document.all.tags("DIV").length() the
code is running well....WHY..?? i realy confuces because
AxWebBrowser1.Document.all it's not in the library but it's not
error.....why..???

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Hi jokolee

AxWebBrowser1.Document is of type Object, which has only one method:
GetType. However, the Document property implements several interfaces, such
as IHTMLDocument and IHTMLDocument2.

Type the following

DirectCast(AxWebBrowser1.Document, mshtml.IHMTLDocument2)

and at the end of the line press . (period). The intellisense should list
the methods and properties supported on this interface.

The reason why your code works is that (I suspect) you have Option Strict
off by default, and this allows late binding. So, at runtime, a check is
made to see if all.tags etc. is supported, which it is, so it works. I would
recommend turning Option Strict on and explicitly qualifying the type of the
objects you are using by applying DirectCast. It might be more typing but it
is more reliable and you will get the benefit of intellisense. It will also
run more quickly because late binding is expensive of time.

HTH

Charles
 

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

Back
Top