 'The Ruby way
    'Socket.ip_address_list.select(&:ipv4?).collect(&:ip_address)
 
   'Amateur's way: With indexed loop
    Function Get_Local_IPv4_Addresses1() As String()
        Dim All_Addresses() As IPAddress
        All_Addresses = Dns.GetHostAddresses(Dns.GetHostName)
        Dim Result() As String = {}
        For i = 0 To All_Addresses.Length - 1
            If All_Addresses(i).AddressFamily = InterNetwork Then
                ReDim Preserve Result(Result.Length)
                Result(Result.Length - 1) = All_Addresses(i).ToString
            End If
        Next
        Return Result
    End Function
 
    'Professional's way. With "for each" loop. No need to declare array to hold results
    Function Get_Local_IPv4_Addresses2() As String()
        Dim Result() As String = {}
        For Each ip In Dns.GetHostAddresses(Dns.GetHostName())
            If ip.AddressFamily = Sockets.AddressFamily.InterNetwork Then
                ReDim Preserve Result(Result.Length)
                Result(Result.Length - 1) = ip.ToString()
            End If
        Next
        Return Result
    End Function
 
    'Expert's way. With generic collections and lambda expressions
    Function Get_Local_IPv4_Addresses3() As String()
        Dim All_Addresses() As IPAddress
        All_Addresses = Array.FindAll(Dns.GetHostAddresses(Dns.GetHostName()), Function(ip) ip.AddressFamily = InterNetwork)
        Return Array.ConvertAll(All_Addresses, Function(ip) ip.ToString())
    End Function