Finding overlapping region between two ranges of integers
If there is any overlapping range ; it must start from the max lower bound to the min upper bound so just use that "formula"
Then just get the number of item in that range by subtracting it's upper bound to it's lower one and add one (to be all inclusive)
Finally if that amount is negative it means that the range weren't overlapping so just get the max between that amount and 0 to handle that case
Edit : Oops C# not VB.Net
int FindOverlapping (int start1, int end1, int start2, int end2)
{
return Math.Max (0, Math.Min (end1, end2) - Math.Max (start1, start2) + 1);
}