Results 1 to 6 of 6

Thread: Separate like values in an array

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2001
    Posts
    20

    Separate like values in an array

    I am pulling an ADO recordset in VB code. the fields in this recordset are "OrderID", and "Industry"

    I am reading these items into an array for processing . Orders next to each other in the array cannot have the same industry if at all possible. I need a way to split them up and guarantee that if I have a situation like 7 orders with three of those belonging to the same industry that they don't end up next to each other.

    Any ideas would be helpful

  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    can you explain why you need that?

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

    Initially read the data into separate arrays, one for each Industry.
    When that is done, loop through the separate arrays and load them into the final array staring with the (0) entry of the individual arrays, followed by the (1) entry of each array, etc.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2001
    Posts
    20
    I need this because I'm creating a play schedule for a video advertising board that rotates a set of advertisments (i.e. 65). As I'm listing these I don't want to have two competing beer ads next to each other in the rotation. Although they can be set one apart (like beer, car dealer, beer, Pest Control, beer)

    The ideas above is decent, save for the fact the the number of arrays could grow pretty large (like > 50) and I don't think I want to declare that many arrays.

  5. #5

  6. #6
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    What about putting values in random indexes in the same array???
    YOu first sort the recordset so that the values which are alike comes together then read the recordset and use randomize and rnd functions to put the values in the array..Well you'll have to check for the bounds and repetition of same index.. but it'd save managing multiple arrays..

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