首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

关于WebBrowser解决方法

2012-01-19 
关于WebBrowserDim UserName, PassWordPrivate Sub Command1_Click()WebBrowser1.Navigate http://emailr

关于WebBrowser
Dim UserName, PassWord
Private Sub Command1_Click()
  WebBrowser1.Navigate "http://emailreg.qq.com/cgi-bin/signup/step1?regtype=0"
End Sub

Private Sub Command2_Click()
  Randomize
  '随机账号
  UserName = "yanhuapiaopiao"
  For i = 1 To 4
  UserName = UserName & Int(Rnd * 10)
  Next
  '密码^_^ 宣传下自己。。
  PassWord = "yanhuapiaopiao"
  Caption = "账号:" & UserName & " 密码:" & PassWord & " 开始注册"
   
  '填写生日
  Set oOption = WebBrowser1.Document.createElement("OPTION")
  oOption.innerText = "6"
  oOption.Value = "6"
  WebBrowser1.Document.getElementsByTagName("select")(3).appendChild (oOption)
  For Each a In WebBrowser1.Document.getElementsByTagName("OPTION")
  If a.Value = "1986" Or a.Value = "6" Then a.Selected = True
  Next
   
  '填写 账号 昵称 密码
  WebBrowser1.Document.getElementsByTagName("INPUT")(2).Value = UserName
  WebBrowser1.Document.getElementsByTagName("INPUT")(4).Value = "烟花飘飘"
  WebBrowser1.Document.getElementsByTagName("INPUT")(7).Value = PassWord
  WebBrowser1.Document.getElementsByTagName("INPUT")(8).Value = PassWord
@这是一位高手的一部分代码,我有些地方看不懂,就是最后那4行,那些2,4,7,8是不是下标呀,我是这样想的。但是打开网页,我怎么也数不对。我觉得对应INPUT来说,不应该是这样吗
  WebBrowser1.Document.getElementsByTagName("INPUT")(1).Value = UserName
  WebBrowser1.Document.getElementsByTagName("INPUT")(2).Value = "烟花飘飘"
  WebBrowser1.Document.getElementsByTagName("INPUT")(3).Value = PassWord
  WebBrowser1.Document.getElementsByTagName("INPUT")(4).Value = PassWord
请高手解答。

[解决办法]
2,4,7,8是INPUT标签的索引,那可不一定是1,2,3,4
[解决办法]

探讨
那怎样知道每个INPUT的索引值还有OPTION的索引值呢

热点排行