Help creating a list of document numbers

I have a data table with rows that contain document numbers. These numbers are in numeric order, but there may be numbers missing from the list. Ex 19001, 19002, 19003, 19006, 19007. In this example I would need to be able to use (19001,19003),(19006,19007) to use in a type into field. How can I choose the numbers while still skipping over the numbers that are missing???
Thanks for the help!!!

Hi,

If the number is sorted and there is no duplicate, the following will work. Can you try this?

arrNum = dt.AsEnumerable.Select(Function(r) Int32.Parse(r("Column1").ToString)).ToArray

Then

arrResult = arrNum.Where(Function(i) not arrNum.Contains(i-1) AndAlso arrNum.Contains(i)).Zip(arrNum.Where(Function(i) not arrNum.Contains(i+1)AndAlso arrNum.Contains(i)),Function(i1,i2) "("+i1.ToString+","+i2.ToString+")").ToArray

Sequence.xaml (7.6 KB)

Regards,

1 Like

Thank you so much. That worked wonderfully!!! I appreciate the help!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.