VB.Net 如何取得實體外部 IP

VB.Net 如何取得實體外部 IP

VB.Net 如何取得實體外部 IP

<< VB.Net >>

Imports System

Imports System.IO

Imports System.Net

Imports System.Text

Public Class Form1

Private Sub Button1_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button1.Click

MessageBox.Show(GetHttpTxt("http://pchelplive.com/ip.php"))

End Sub

Private Sub Button2_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button2.Click

MessageBox.Show(GetWebTxt("http://pchelplive.com/ip.php"))

End Sub

Private Function GetHttpTxt(ByVal URL As String) As String

Dim stm As Stream = HttpWebRequest.Create(URL).GetResponse.GetResponseStream

Return New StreamReader(stm, True).ReadToEnd

End Function

Private Function GetWebTxt(ByVal URL As String) As String

Dim stm As Stream = WebRequest.Create(URL).GetResponse.GetResponseStream

Return New StreamReader(stm, True).ReadToEnd

End Function

End Class

' ================================================================

<< VB6 >>

MsgBox CreateObject("InetCtls.Inet").OpenURL("http://pchelplive.com/ip.php")