We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
<!--- always sort first so the ranges make sense ---> <cfset numbers = listToArray("1,2,3,4,6,7,8,9,10,11,12,15,19,21,22")> <cfset arraySort(numbers, "numeric")> <cfset startAt = 1> <cfset maxPosition = arrayLen(numbers)> <cfset ranges = > <cfloop from="1" to="#maxPosition#" index="pos"> <!--- check difference between current and next number ---> <cfset offset = pos lt maxPosition ? 1 : 0> <cfset gap = numbers[pos+offset] - numbers[pos]> <!--- there was a jump in sequence OR this is the last element ---> <cfif gap gt 1 OR pos eq maxPosition> <cfif startAt lt pos> <!--- range ---> <cfset arrayAppend(ranges, numbers[startAt] &"-"& numbers[pos])> <cfelse> <!--- single value ---> <cfset arrayAppend(ranges, numbers[pos])> </cfif> <cfset startAt = pos + 1> </cfif> </cfloop> List of Ranges: <cfdump var="#arrayToList(ranges, ',')#">
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|vb.net datagrid scroll automatically to the first found row||11||44|
|.Net remove carriage returns, line feeds and tabbs||5||33|
|How to embed a manual into my vb 2005 project||7||24|
Join the community of 500,000 technology professionals and ask your questions.