Calculate Network Address

Here is a little console application I created that can take an ip and subnet mask and give you the network address. 

Module Module1

    Sub Main()
        Console.WriteLine("Enter the IP address")
        Dim sIP As String = Console.ReadLine()
        Console.WriteLine("Enter Subnet Mask")
        Dim sSubnetMask As String = Console.ReadLine()
        Dim ip() As String = sIP.Split(".")
        Dim subnetmask() As String = sSubnetMask.Split(".")
        Console.WriteLine("The network address is:")
        For i As Integer = 0 To 3
            If i > 0 Then
                Console.Write(".")
            End If
            Console.Write(ip(i) and subnetmask(i))
        Next
        Console.WriteLine("")
        Console.ReadLine()
    End Sub

End Module

EDIT: I was really not thinking clearly when I wrote the original.  Thanks to TheMoof for pointing this out.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s