By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Identify all numbers between two values

P: n/a


Hi,

If i have a start value (i.e. 920001) and an end value (i.e. 935000)
and i want to pick out every number between the two values and then,
for example, store it in an array. How would i go about this i.e.
identifying each integer value between these two values.

Thanks for any and all help.

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
kieran,
Have you tried a For loop?

Something like:

Dim values(935000 - 920001) As Integer

For index As Integer = 920001 To 935000
values(index - 920001) = index
Next

Alternatively you could use an ArrayList:

Dim list As New ArrayList
For index As Integer = 920001 To 935000
list.Add(index)
Next

Hope this helps
Jay

"kieran" <ki********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
|
|
| Hi,
|
| If i have a start value (i.e. 920001) and an end value (i.e. 935000)
| and i want to pick out every number between the two values and then,
| for example, store it in an array. How would i go about this i.e.
| identifying each integer value between these two values.
|
| Thanks for any and all help.
|
Nov 21 '05 #2

P: n/a

"kieran" <ki********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...


Hi,

If i have a start value (i.e. 920001) and an end value (i.e. 935000)
and i want to pick out every number between the two values and then,
for example, store it in an array. How would i go about this i.e.
identifying each integer value between these two values.

Thanks for any and all help.


Dim arr As Integer()
Dim value1 As Integer = 920001
Dim value2 As Integer = 935000
Dim maxValue As Integer = Math.Max(value1, value2)
Dim minValue As Integer = Math.Min(value1, value2)

ReDim arr(maxValue - minValue)

For i As Integer = 0 To (maxValue - minValue)
arr(i) = (minValue + i)
Next
The above example is just that, an example. Quick and dirty with some
extra's thrown in just in case :)

HTH,

Mythran

Nov 21 '05 #3

P: n/a


both work great...thanks!!!

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.