Visual Basic Code Snippet - Get local computer host name

Visual Basic Code Snippet - Get local computer host name

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.

1''' <summary>
2''' Gets host name of the local computer
3''' </summary>
4Public Function GetLocalHostName() As String
5    Return System.Net.Dns.GetHostName()
6End Function


Here is a simple example showing how to use above function (GetLocalHostName) to display local machine host name.

1Console.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:

Leave a comment

 Poster Information 


(will not be published, required)

 MESSAGE DETAILS