AuthorMessage
C0D3Z3R0
Pro
Posts: 166

Tutorial Level: Beginners
This is one of my first vb.net tutorials so leave comments so I know if people have done this and if you changed something then post what you changed
First open Visual Studio .NET and create a new Windows Application.
Now create 2 labels that are labeled "IP:" and "Domain:" and 2 text boxes that are empty and create a button with "Resolve Domain" as the buttons text.
Arrange the button and the labels etc on the form so that they look good where they are and now we can start coding
Double click on the button that you created on the form and it will show you the code view, there is already some code on the screen but that isn't much use to us since it does nothing yet.
Before we can start coding add the System.Net namespace by going to the top of all the code and add:
Code:

Imports System.Net

Now add the following code for the button:
Code:
TextBox1.Text = ""

This clears the textbox every time the button is clicked so that the text box doesn't fill up with a lot of different IP's from different domains you resolved.
Next add the following code:
Code:

        Dim entry As IPHostEntry
        Try
            entry = Dns.Resolve(TextBox2.Text)
            For Each ip As IPAddress In entry.AddressList
                TextBox1.AppendText(ip.ToString())
            Next
        Catch ex As Exception
            TextBox1.AppendText("Error resolving hostname")
        End Try
    End Sub

This code will resolve the domains IP address and append the IP to the textbox that we added to our form earlier, if there are problems resolving the domain, such as if the domain no longer exists then it will append the text "Error resolving hostname" instead so that you know there is a problem with that domain.
Here is the code I have at the end of this:
Code:

Imports System.Net
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        Dim entry As IPHostEntry
        Try
            entry = Dns.Resolve(TextBox2.Text)
            For Each ip As IPAddress In entry.AddressList
                TextBox1.AppendText(ip.ToString())
            Next
        Catch ex As Exception
            TextBox1.AppendText("Error resolving hostname")
        End Try
    End Sub
End Class

To run this code go to the start button at the top of the screen and it should run without any errors, if you get errors then post back with your code and I'll help you fix it. If you want to compile this program to give to friends or because you want to use it then click on the build tab at the top and click build "yourappname". It should then build straight away and you can run it from going to the directory where it has compiled and clicking on it
Hopefully this small tutorial was useful but if there are any questions then feel free to ask, don't pm me for info, ask in the forums so that the information is on the forums for others