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
120 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
  • 3
  • 2
6 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
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
Comment Utility
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 62

Expert Comment

by:Fernando Soto
Comment Utility
How do you determine what list/range of numbers are to be in the list to be able to create the list programmatically?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:taviaf
Comment Utility
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
Comment Utility
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 62

Expert Comment

by:Fernando Soto
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now