PDA

Click to See Complete Forum and Search --> : array


Juillet
Dec 6th, 1999, 07:50 PM
I have an array of 7 values
1,4,4,5,8,8,8
I want to sort and use a bubble sort.
No problem
What I would like to know is how to increment any value that is equal to the one prior to it by 1.
When I incremnt the 3rd index(4) it becomes 5 and then the fourth index mathes the 3rd so it gets incremented and so on.

I would like to end up with
1,4,5,6,8,9,10


Thanks

MartinLiss
Dec 6th, 1999, 09:23 PM
here you go.

For intIndex = 0 To UBound(intArray) - 1
If intArray(intIndex) >= intArray(intIndex + 1) Then
intArray(intIndex + 1) = intArray(intIndex) + 1
End If
Next intIndex


------------------
Marty

Serge
Dec 6th, 1999, 09:27 PM
This message has been deleted, since you got the reply from Marty.

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)



[This message has been edited by Serge (edited 12-07-1999).]

Juillet
Dec 7th, 1999, 01:05 AM
Thank you!