内外ip
Dim IPAdress As System.Net.IPAddress
Dim HostName As String
HostName = System.Net.Dns.GetHostName '获得本机的机器名
Dim l As Integer = System.Net.Dns.GetHostByName(HostName).AddressList.Length
For i As Integer=0 To l-1
IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.getValue(i) '获得本机的IP
output.show(IPAdress.Tostring)
Next
外网ip
Dim WinHttpReq As Object = CreateObject("Msxml2.ServerXMLHTTP")
WinHttpReq.Open("GET", "http://1212.ip138.com/ic.asp")
WinHttpReq.Send
'正则表达式解析出外网IP
Dim str As String = WinHttpReq.ResponseText
Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
If mc.count > 0 Then
msgbox(mc(0).value)
End If