This function is able to read out your own IP address you got assigned from your internet provider. Even if you are using a router. This works because the function sends a request to a website which contains your IP address.
Translate to C#
Public Function GetExternalIP(ByVal Provider As String) As String
Dim WebReq As HttpWebRequest = HttpWebRequest.Create(Provider)
Dim WebRes As HttpWebResponse = WebReq.GetResponse()
Dim ResStream As System.IO.Stream = WebRes.GetResponseStream
Dim ResStreamReader As New StreamReader(ResStream, Encoding.UTF8)
Dim IP As String = ResStreamReader.ReadToEnd