How to get computer name and IP address?
The following code uses the System.NET.DNS namespace to access the "computer name" and it's IP address.
Option Strict Off
Imports system
Imports System.Net.DNS
Public Class GetIP
Shared Function GetIPAddress() As String
Dim sam As System.Net.IPAddress
Dim sam1 As String
With system.Net.DNS.GetHostByName(system.Net.DNS.GetHostName())
sam = New System.Net.IPAddress(.AddressList(0).Address)
sam1 = sam.ToString
End With
GetIPAddress = sam1
End Function
Shared Sub main()
Dim shostname As String
shostname = system.Net.DNS.GetHostName
console.writeline("Name of the System is = " & shostname)
console.writeline("Your IP address is= " & GetIPAddress)
End Sub
End Class
Compile the file as "vbc getip.vb /r:system.net.dll"
Execute the "getip.exe". The computer's name and IP address will be displayed in the Console.
Written by Sandeep Mogulla, Webmaster at www.startvbdotnet.com
Index
Sponsored links
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Add complete SSH and SFTP support to your .NET framework application
3 Months Free - ASP.NET Web Hosting
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
