Visual Basic Code Snippet - Get local computer host name
(VB) Visual Basic code snippet get the host name from the local machine.
Bookmark:
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.
4 | Public Function GetLocalHostName() As String |
5 | Return System.Net.Dns.GetHostName() |
Here is a simple example showing how to use above function (GetLocalHostName) to display local machine host name.
1 | Console.WriteLine( "Local computer host name : " & GetLocalHostName()) |
VB Keywords Used:
Code Snippet Information:
- Applies To: Visual Studio, .Net, VB, Visual Basic, CLI, DNS, Domain Name System, GetHostName
- Programming Language : Visual Basic (VB)
External Resources: