Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello... Good day to all you... i just want to ask if is there something wrong with my codes in finding my own ipaddress using other networked PC...
VB
dim strhostname as string 
dim strIPaddress as string
strhostname = "mycomputer's_hostname"
strhostname = system.net.dns.gethostname()
stripaddress = system.net.dns.gethostname(strhostname).addresslist(0).tostring()
textbox1.text = stripaddress

i already had my import like system.net. Anybody here could help me? i tried this code but it didn't work... is there any shorter way than this? thanks in advance..
Posted
Updated 7-Mar-12 5:53am
v2
Comments
Dave Kreskowiak 7-Mar-12 12:55pm    
Ok, so you're trying to get your machines IP address from DNS. So what's the problem?

1 solution

Take a look at the following link:

How To Get IP Address Of A Machine[^] also, take a look at the comments, better way to get the IP is:

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].GetIPProperties().UnicastAddresses[0].Address

Also, Local IP[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900