Foxtable(狐表)用户栏目专家坐堂 → 代码提示出错


  共有3247人关注过本帖树形打印复制链接

主题:代码提示出错

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/7/9 19:22:00 [显示全部帖子]

Dim web As New System.Windows.Forms.WebBrowser()
web.Navigate("http://ip.qq.com/")
Do Until web.ReadyState = 4
    Application.DoEvents
Loop
Dim elems As System.Windows.Forms.HtmlElementCollection
Elems = web.Document.GetElementsByTagName("Body")   '根据标签得到数据集合
Dim data As String = elems(0).InnerText
Dim start As Integer = data.IndexOf("IP为") + 4
Dim ip91 As String =trim(data.SubString(start,15)) 'IP地址,最多15个字符
Dim i As Integer
Dim j As String
For i =8 To 15 'IP地址至少7位
    j =mid(ip91,i,1)
    If j=chr(10) Then
        ip91=mid(ip91,1,i-1) '最终的IP地址
        Exit For
    End If
Next
start = data.IndexOf("IP所在地为") + 9
Dim ip92 As String=trim(data.SubString(start,15)) 'IP地址对应的城市,最多15个字符
For i  =6 To 15 '城市最少5个字符
    j =mid(ip92,i,1)
    If j=" " Then
        ip92=mid(ip92,1,i-1) '最终的城市,忽略后面的运营商
        Exit For
    End If
Next
ip91=ip91 & "|" & ip92 '合并
msgbox(ip91)
'End If

 回到顶部