您的位置:程序门 -> .net技术 -> vb.net



webbrowser1.document 不能转换成 mshtml.htmldocument


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


webbrowser1.document 不能转换成 mshtml.htmldocument[已结贴,结贴人:hwmfly]
发表于:2007-01-29 20:42:06 楼主

dim   doc   as   mshtml.htmldocument
doc   =   webbrowser1.document

错误提示:
unable   to   cast   object   of   type   'system.windows.forms.htmldocument '   to   type   'mshtml.htmldocument '.

开发环境   vb.net   2005

相关资料查找及背景介绍:

我以前用vb写的分析网页的代码,webbrowser1   和   mshtml配合的很好,现在想把它用vb.net   2005重写,第一步就被卡住了如果我使用   system.windows.forms   命名空间中的htmldocument(system.windows.forms.htmldocument   )
就没有这个类型转换问题。但是system.windows.forms   命名空间中的类型太少,比如我要对表格进行控制,他就没有ihtmltable类型。

我用各种方法进行搜索收获不大,只得到一点提示,说是   .net   中的com是unmanged代码不能直接使用,mshtml正是com。
http://www.zhuye123.com/article/156/161/2006/2006042328784.html
http://www.evget.com/article/read_1061.aspx

就是没有找到解决办法,请高手指点。。

谢过!!!

发表于:2007-01-30 07:52:571楼 得分:30
dim   doc   as   mshtml.ihtmldocument2
doc   =   webbrowser1.document.domdocument
发表于:2007-01-30 08:32:532楼 得分:70
现在统一使用htmlelement和dom方式操作了

        dim   doc   as   htmldocument
        dim   table   as   htmlelement
        dim   tables   as   htmlelementcollection
        doc   =   webbrowser1.document
        tables   =   doc.getelementsbytagname( "table ")
        for   i   as   integer   =   0   to   tables.count   -   1
            table   =   tables(i)
            messagebox.show(table.firstchild.tagname)
        next
发表于:2007-02-03 10:16:433楼 得分:0
to:
jiangsheng(蒋晟.net[mvp])  
net_lover(【孟子e章】)  

谢谢两位大虾,你们的方法都可以用
是不是vs2005不推介使用mshtml.ihtmldocument2

发表于:2007-02-21 13:43:394楼 得分:0
该回复于2007-12-21 19:40:05被管理员或版主删除


快速检索

最新资讯
热门点击