Results 1 to 4 of 4

Thread: array

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    40

    Post

    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

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    here you go.

    Code:
    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

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    This message has been deleted, since you got the reply from Marty.

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

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



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

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    40

    Post

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width