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.

Leave a comment