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
121 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
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 62

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 62

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

16 Experts available now in Live!

Get 1:1 Help Now