【问题标题】:How to convert IP Address to IP HostEntry in VB.NET?如何在 VB.NET 中将 IP 地址转换为 IP HostEntry?
【发布时间】:2013-03-19 19:17:13
【问题描述】:

我正在构建一个小型应用程序,它会在您将 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

【问题讨论】:

    标签: vb.net ip ip-address


    【解决方案1】:
    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-05-09
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      • 1970-01-01
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多