Visual Basic Code Snippet - Get local computer host name
Visual Basic Code Snippet - Get local computer host name
This .Net Visual Basic code snippet get the host name from the local machine. This function uses System.Net namespace to get local machine hostname. Modify the exception handling section to meet your project requirements.
''' <summary> ''' Gets host name of the local computer ''' </summary> Public Function GetLocalHostName() As String Return System.Net.Dns.GetHostName() End Function
Here is a simple example showing how to use above function (GetLocalHostName) to display local machine host name.
Console.WriteLine("Local computer host name : " & GetLocalHostName())
VB Keywords Used:
- DNS
- GetHostName
- Exception
Code Snippet Information:
- Applies To: Visual Studio, .Net, VB, Visual Basic, CLI, DNS, Domain Name System, GetHostName
- Programming Language : Visual Basic (VB)
External Resources: