Private Function IPAddress() As String
Dim strIP As String = ""
Dim LocalHostName As String
Try
LocalHostName = Dns.GetHostName()
Dim ipEnter As IPHostEntry = Dns.GetHostEntry(LocalHostName)
Dim IpAdd() As IPAddress = ipEnter.AddressList
strIP = IpAdd(0).ToString()
Return strIP
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
With C# CODE-->
private string IPAddress()
{
string strIP = "";
string LocalHostName = null;
try {
LocalHostName = Dns.GetHostName();
IPHostEntry ipEnter = Dns.GetHostEntry(LocalHostName);
IPAddress[] IpAdd = ipEnter.AddressList;
strIP = IpAdd(0).ToString();
return strIP;
} catch (Exception ex) {
throw new Exception(ex.Message);
}
}