calculating and adding a range to a collection

  • Thread starter Thread starter marola20
  • Start date Start date
M

marola20

Ok, this one might take me a minute to explain.
I'm trying to capture a list of numbers (mostly)...and add them to
collection. My test "string" is:
1001, 1003, 1005-1007, 1008, 1009, 1010-1019, 1022

I am able to add the individual numbers "1001" just fine. What I don
know how to do is calculate and add the ranges "1005-1007."
To make matters worse, the nubmers and ranges can begin with a letter.
I'm not so concerned with getting an answer on the leading lette
problem, but a nudge in the right direction on calculating the rang
would be great.

Thanks, M
 
Hi Marola,

Firstly use Split to split it into an array with the - as the split
character (assuming that you have already stripped the alphas).

Then do a simple loop on these 2 numbers adding to the collection

For i = aryNums(0) to aryNums(1)
myColl.Add Cstr(i),Cstr(i)
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top