Essential Functions: getLocalIp() and ByteArToHex()

That I don’t want to re-write in case my hard drive breaks, all public domain:

Private Function getLocalIp() As String

        Dim myips As Net.IPHostEntry = System.Net.Dns.GetHostEntry(Net.Dns.GetHostName)

        Dim myip As String = “”

        For Each ipaddress As Net.IPAddress In myips.AddressList
            If ipaddress.ToString.Split(“.”).Count = 4 Then
                If ipaddress.ToString <> “” Then
                    myip = ipaddress.ToString
                    Exit For
                End If
            End If

        Return myip

    End Function



    Private Function ByteArToHex(ByVal byteAr As Byte())
        Dim s1 As String = “”
        For Each c1 As Byte In byteAr
            s1 = s1 + String.Format(“{0:X2}”, c1)

        Return s1

    End Function



Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s