# I want to create a list of number ranges like: lanes 4-6, 11-13, and 18-20

I want to create a list of number ranges like: lanes 4-6, 11-13, and 18-20.
I am currently saving the list as PointFiveList="4, 5, 6, 11, 12, 13, 18, 19, 20"
I would like to be able to do this no matter how many numbers are entered and as well if the numbers are not consecutive.

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RetiredCommented:
You can use the Enumerable.Range(StartInteger, NumberOfValuesInTheRange). For example lest say you wanted a list of integers starting at the number 9 with 5 consecutive values you could do this.

Dim lanes List(Of Integer) = Enumerable.Range(9, 5)

Will result with the list of integers 9, 10, 11, 12, 13.
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
that can help with part maybe but my list is more like 4,5,6,11, 12,13,18,19,20 and then I may have another like 1,2,3,7,8,9,14,15,16
0
RetiredCommented:
How do you determine what list/range of numbers are to be in the list to be able to create the list programmatically?
0
Author Commented:
Lets say that I have rows 1 - 25 and there are 3 different categories (A, B , C)  which are checkboxes.  I an trying to group the different checkboxes, below.

c= 10, 17 and 24
b = 4, 5, 6, 11, 12, 13, 18, 19 and 20
a = 7, 8, 9, 14, 15, 16, 21, 22 and 23

I want the data to show like:
b= (4-6), (11-13) and (18-20)
a= (7-9), (14-16) and (21-23)
0
Commented:
Algorithm would be

1) Add numbers to an array
2) Sort the array
3) Loop through the array, first number is the start of the next range, when next number - current number is more than 1 then current number is the end of current range and next number is the start of next range.
0
RetiredCommented:
When you say you have, "Lets say that I have rows 1 - 25", are these rows in a DataTable object and the DataTable has 3 columns which each of the three columns has a check box and you want to produce the following results depending on which check box has a check mark?

b= (4-6), (11-13) and (18-20)
a= (7-9), (14-16) and (21-23)

If that is the case the use of the first 3 variables a, b, c look like integers but the second group of a, b, c are not integers because they would contain invalid character such as (7 - 9) would not be an integer.

Is my understanding correct or not? If it is not correct can you give a more detail description of what you have to work with, the type of object and initial state, and what you want the end results to look like objects and states.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.