PDA

View Full Version : How to make a program that converts hostnames to IPs?


mark1221
12-13-2004, 10:01 AM
Hey there!
I would really appreciate if any of you guys could tell me how to build something (using VB.NET) that converts host-names to IPs,
Like converting www.hotsname.com to 133.000.234.0,
Thanks everyone! :D

mark1221
12-13-2004, 01:08 PM
Ok here's a little update:

After alot of google searching i found namespace system.net
And here is what i came up to:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim host As System.Net.IPHostEntry
Dim ip As String
host = Dns.GetHostByName("www.blahhost.com")
ip = host.AddressList(0).ToString()
ComboBox1.Items.Add(ip)
End Sub


Now the weird thing is that it gives me an error:
Object reference not set to an instance of an object.

And the faulty line is the last one:
ComboBox1.Items.Add(ip)
I don't know what's wrong but i really need help!

When the program runs the variable ip gets the right value, but it can't output it :(