April 25, 200223 yr I am making a calculation that compares IP addresses to see if they are the same. That is easy enough, but I also want to check to see if they are on the same sub net. for example: 55.56.57.56 55.56.57.69 are not the same IP but they are on the same subnet, because the first 3 numbers on the same but the last is different. But each of the numbers can be 1 to 3 digits and can't just compare the left X numbers, i just want to see if the first 3 are the same. How would your left brain do that?
April 26, 200223 yr You need to treat the IP address as a text string. This test will return a 1 if the subnets match (1.2.3.x = 1.2.3.y) Left(IP1, Position(IP1, ".", 1, 3) - 1) = Left(IP1, Position(IP2, ".", 1, 3) - 1) -bd
April 29, 200223 yr Be careful. The first 3 numbers do not necessarily specify the subnet. You need to check the subnet mask. If it's 255.255.255.0 then fine, but this isn't always the case in large organizations with large networks.
Create an account or sign in to comment