en teoria, el primer valor del array es la IP, asi que no hace falta hacer el bucle for.
TextBox1.Text = ip(0).ToString
Hombre en teoría es la IP ya que es una lista de direcciones, el problema es que a veces el primer item de la colección suele ser una IPv6, a mi también me dió problemas en el pasado.
Bueno, he escrito un ejemplo para ayudarte a obtener las IPv4 asociadas con "X" página
Modo de empleo:
Dim IPv4List As New List(Of String)(HostNameToIP("foro.elhacker.net", Net.Sockets.AddressFamily.InterNetwork))
Dim IPv6List As New List(Of String)(HostNameToIP("LOCALHOST", Net.Sockets.AddressFamily.InterNetworkV6))
MessageBox.Show(IPv4List(0)) ' Result: 108.162.205.73
MessageBox.Show(IPv6List(0)) ' Result: ::1
Source:
' HostName To IP
' By Elektro
'
' Usage Examples :
' MessageBox.Show(HostNameToIP("foro.elhacker.net", Net.Sockets.AddressFamily.InterNetwork).First)
'
''' <summary>
''' Gets the specified addresses associated to a Host.
''' </summary>
''' <param name="hotsName">The Host name.</param>
''' <param name="addressFamily">The address family.</param>
''' <returns>The addresses.</returns>
''' <exception cref="System.NotImplementedException">Address filtering not implemented yet.</exception>
Public Function HostNameToIP(ByVal hotsName As String,
ByVal addressFamily As Net.Sockets.AddressFamily) As IEnumerable(Of String)
Dim hostInfo As Net.IPHostEntry = Net.Dns.GetHostEntry(hotsName)
Dim addressList As IEnumerable(Of String)
Try
hostInfo = Net.Dns.GetHostEntry(hotsName)
Select Case addressFamily
Case Net.Sockets.AddressFamily.InterNetwork,
Net.Sockets.AddressFamily.InterNetworkV6 ' IPv4, IPv6.
addressList = From address As Net.IPAddress In hostInfo.AddressList
Where address.AddressFamily = addressFamily
Select (address.ToString)
Case Else
Throw New NotImplementedException("Address filtering not implemented yet.")
End Select
Catch ex As Net.Sockets.SocketException
Throw
Catch ex As ArgumentNullException
Throw
Catch ex As Exception
Throw
End Try
Return addressList
End Function