本文介绍了外部和内部IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的错误在哪里?
Where is my mistake?
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Internal
Try
Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
Dim strLocalIp As String = h.AddressList.GetValue(0).ToString
TextBox1.Text = strLocalIp
Catch EX As Exception
End Try
'External
Dim web As New System.Net.WebClient
Dim myIP As String
myIP = System.Text.Encoding.ASCII.GetString(( _
web.DownloadData("http://whatismyip.com/automation/faq/n09230945.asp")))
TextBox2.Text = myIP
End Sub
End Class
推荐答案
这篇关于外部和内部IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!