i tried this code... but it returned my internal IP Address...
Expand|Select|Wrap|Line Numbers
- Dim IPHost As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
- MessageBox.Show("My IP address is " & IPHost.AddressList(0).ToString())
and i tried this code too...
Expand|Select|Wrap|Line Numbers
- Imports System
- Imports System.Text
- Imports System.Text.RegularExpressions
- Public Sub GetExternalIP()
- Dim whatIsMyIp As String = "http://whatismyip.com"
- Dim getIpRegex As String = "(?<=<TITLE>.*)\d*\.\d*\.\d*\.\d*(?=</TITLE>)"
- Dim wc As WebClient = New WebClient
- Dim utf8 As UTF8Encoding = New UTF8Encoding
- Dim requestHtml As String = ""
- Dim externalIp As IPAddress = Nothing
- requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp))
- Dim r As Regex = New Regex(getIpRegex)
- Dim m As Match = r.Match(requestHtml)
- If (m.Success) Then
- externalIp = IPAddress.Parse(m.Value)
- MessageBox.Show(externalIp.ToString)
- End If
- End Sub
using command window - Immediate, i get values for "r" and "m". and m.success = false...
? ri don't have fire wall setup in my machine. and i have internet access too...
{System.Text.Re gularExpression s.Regex}
Options: None
RightToLeft: False
? r.Match(request Html)
{System.Text.Re gularExpression s.Match}
Captures: {System.Text.Re gularExpression s.CaptureCollec tion}
Empty: {System.Text.Re gularExpression s.Match}
Groups: {System.Text.Re gularExpression s.GroupCollecti on}
Index: 0
Length: 0
Success: False
Value: ""
anything wrong in that code.. or anything i'm missing... if anyone have any idea how to find out the External Ip Address, please help me. if you can provide an example, then it will be a great help for me.
Thanks in advance.