Solved

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

Posted on 2014-07-21
6
125 Views
Last Modified: 2014-07-22
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.

Please help....
0
Comment
Question by:taviaf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40210669
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
 

Author Comment

by:taviaf
ID: 40211567
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
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40211588
How do you determine what list/range of numbers are to be in the list to be able to create the list programmatically?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:taviaf
ID: 40211656
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 40211765
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
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40211776
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

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question