下载网页,将其存储在文本框 ( text1.text = Inet1.OpenURL("http://www..."
) 或字符串中。
使用 vb.nets 字符串操作函数从字符串中提取数据。
http://msdn.microsoft.com/en-us/library/aa903372(v=vs.71).aspx
http://www.thevbprogrammer.com/VBNET_04/04-08-StringHandling.htm
下面的示例代码从网站中提取 IP 地址。
Option Explicit
' Add Microsoft Internet Transfer Control
Dim pubIPA As String, pos1 As Long, pos2 As Long, str As String
Private Sub Form_Load()
str = Inet1.OpenURL("http://api.externalip.net/ip/", icString)
pos1 = InStr(str, "var ip =")
pos1 = InStr(pos1 + 1, str, "'", vbTextCompare) + 1
pos2 = InStr(pos1 + 1, str, "'", vbTextCompare)
pubIPA = Mid$(str, pos1, pos2 - pos1)
MsgBox pubIPA, vbInformation
Unload Me
End Sub
http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/105605a1-4d1a-4bc8-8a13-c9cc6748065e
http://www.dreamincode.net/forums/topic/95117-get-string-between-2-values/
http://www.example-code.com/vb/findSubstring.asp
http://www.dreamincode.net/forums/topic/66912-finding-a-string-within-a-string/
http://www.dotnetperls.com/indexof-vbnet