navin solanky
navin solanky

Reputation: 21

How do I get a computer's programing name and static IP address using VB.NET?

Public Function GetComputerName() As String
    Dim ComputerName As String
    ComputerName = System.Net.Dns.GetHostName
    Return ComputerName
End Function

Upvotes: 0

Views: 335

Answers (1)

Jande
Jande

Reputation: 1705

For PC name use:

 My.Computer.Name

For IP use:

 Private Sub GetIPAddress()

 Dim strHostName As String 
 Dim strIPAddress As String

 strHostName = System.Net.Dns.GetHostName()

 strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()


MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)

End Sub

Upvotes: 2

Related Questions