Identify all numbers between two values

  • Thread starter Thread starter kieran
  • Start date Start date
K

kieran

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.
 
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

|
|
| 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.
|
 
kieran said:
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
 

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