当前位置:编程学习 > VB >>

关于VB点IE网页中的链接的方法

看了很多朋友的帖子,自己试了下,还是不行, 
假如我现在的网页内有 

<a   href= "http://www.hao123.com "> <u> 修改 </u> </a> 

我想用VB写个程序,可以点IE中   修改   这个链接.我试了这个方法 

Private   Sub   Command1_Click() 
Dim   vTag,   vDoc 
Dim   Allcount,   i 
List1.Clear 
Set   vDoc   =   WebBrowser1.Document.All 
Allcount   =   vDoc.length 
Print   Allcount 
For   i   =   0   To   Allcount   -   1 
If   UCase(vDoc.Item(i).TagName)   =   "a   "   Then                       ''找到URL 
vTag   =   vDoc.Item(i).href 
If   InStr(vTag,   "hao123 ")   Then                   ''检测URL中是否含有http://dhunter.51.net 
vDoc.ITEM(i).click       '   '如果有,则添加到list1中 
End   If 
End   If 
end   sub 

不行 

而且, 
Private   Sub   Command1_Click() 
Dim   vTag,   vDoc 
Dim   Allcount,   i 
List1.Clear 
Set   vDoc   =   WebBrowser1.Document.All 
Allcount   =   vDoc.length 
Print   Allcount 
For   i   =   0   To   Allcount   -   1 
If   UCase(vDoc.Item(i).TagName)   =   "a   "   Then                       ''找到URL 
vTag   =   vDoc.Item(i).href 
print   vtag 
End   If 
end   sub 
竟然什么都不显示, 

我想知道为什么, 
我知道原理是   首先从原代码中找到   "a "     但是具体的代码应该是什么样的,请帮助我,谢谢 --------------------编程问答-------------------- <input   id= "in_name "   name= "in_name "   maxlength= "11 "   class= "text "   le= "width:149px; "/> 
<input   id= "in_password "   name= "in_password "   type= "password "   class= "text "   style= "width:126px; "/> 
<input   type= "image "   src= "images/mfs2/mfw/l01.gif "   id= "Login "   style= "margin-left:190px; "/> 

WebBrowser1.Document.All( "in_name ").Value   =   "123456 "           '帐号 
WebBrowser1.Document.All( "in_password ").Value   =   "xxxxx "       '密码   
WebBrowser1.Document.All( "Login ").Click         '点击提交按钮 --------------------编程问答-------------------- 这个我知道,你自动登陆的
比如下面的代码
<p<a href=   "http://www.hao123.com">打开</a> </p> 
<p<a href=   "http://www.baidu.com">打开</a> </p> 
<p<a href=   "http://www.google.com">打开</a> </p> 
<p<a href=   "http://www.tom.com">打开</a> </p> 

在一个网页中有 四个打开的链接,代码分别是上面的
我现在要程序点  链接是  www.google.com  打开  怎么操作
--------------------编程问答-------------------- 我想,这不能愿你,只能怪CSDN总是在引号中加代一些空格!!
不过,复制别人的代码也最好细看看
"a"
不等于"a " --------------------编程问答-------------------- 调用例:
  ShellExecute Me.hwnd, "", _
          "http://www.pcsoft.com.cn/Soft/Soft_6968.htm", _
          "", "", 1
          '用浏览器浏览网页,华军商城
补充:VB ,  基础类
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,