0
Public Function GetComputerName() As String
    Dim ComputerName As String
    ComputerName = System.Net.Dns.GetHostName
    Return ComputerName
End Function
1
  • We need more than just code - we need to see an MCVE, a detailed description of your goal, and the exact error or problematic output you're getting. See How to Ask. Commented Apr 19, 2016 at 18:55

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.