0

我正在构建一个小型应用程序,它会在您将 IP 地址输入到屏蔽文本框中后更改它。我真的很接近弄清楚,但我需要 h = myNewIP 部分的帮助,因为我无法从 IP 地址转换为 IP 主机条目:

Public Class MainForm
Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)
Dim myNewIP As System.Net.IPAddress
Dim myIPEndPoint As System.Net.IPEndPoint
Dim strLocalIp As String

Private Sub
        myNewIP = System.Net.IPAddress.Parse(TextBox1.Text)
        myIPEndPoint = New System.Net.IPEndPoint(myNewIP, 0)
        h = myNewIP
        ipTextBox.Text = myNewIP.ToString
End Sub
4

1 回答 1

0
IPEndPoint endpoint = new IPEndPoint(System.Net.IPAddress.Parse("your ip"), 1111);

只是关于这条线的一条建议:

Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)
Dim myNewIP As System.Net.IPAddress
Dim myIPEndPoint As System.Net.IPEndPoint
Dim strLocalIp As String

如果它们在一种方法中使用,则仅在本地声明它们。

于 2013-03-29T04:30:27.643 回答