Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to realice permutations in a VBA Programm

how to realice permutations in a VBA Programm

Scheduled Pinned Locked Moved Visual Basic
tutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephan Wright
    wrote on last edited by
    #1

    hy everyone I do want to realice a kind of permutation in a VBA programm Lets say I do have the three integer pairs "100 - 120", "200 - 220" and "300 - 320". Now I would like to let my programm select every possible permution of them, meaning the lowerone of the first, the lower one of the second and the lowerone of the third. Let me describe with a set of two pairs. Lets say I do have the pairs "1 - 2" and "3 - 4" so my proggy should allow to access every permution, either for output or for furter use. Well I will have to get "1 3" "1 4" "2 3" and "2 4". This should work for every amount of pairs available. Lets say 16 or 20 pairs with a lower and higher number. I thought about an inner and outer loop but this way I was not able to get all the permutations. Does anyone of you know how to realice that. Thanks! Stephan.

    S 1 Reply Last reply
    0
    • S Stephan Wright

      hy everyone I do want to realice a kind of permutation in a VBA programm Lets say I do have the three integer pairs "100 - 120", "200 - 220" and "300 - 320". Now I would like to let my programm select every possible permution of them, meaning the lowerone of the first, the lower one of the second and the lowerone of the third. Let me describe with a set of two pairs. Lets say I do have the pairs "1 - 2" and "3 - 4" so my proggy should allow to access every permution, either for output or for furter use. Well I will have to get "1 3" "1 4" "2 3" and "2 4". This should work for every amount of pairs available. Lets say 16 or 20 pairs with a lower and higher number. I thought about an inner and outer loop but this way I was not able to get all the permutations. Does anyone of you know how to realice that. Thanks! Stephan.

      S Offline
      S Offline
      Stephan Wright
      wrote on last edited by
      #2

      Well I realized I do not need every permutation, I do only need any combination of the min max values lets have alook at the followin example lets say I do have the intervals "A - B", "C - D" and "E - F" now I do want to get any min max combination (because I do want to use this for an addfunction there is no different if lets say A is in first, second or third place. Meaning e.g. ACE = CEA = EAC etc. Therefor I do only need ACE, ACF, ADE, ADF, BCE, BCF, BDE and BDF. Every other combination is not needed because plus is commutativ (see above) If you do have a look at this with it's index then you might realice there is every bitcombination in it. Because lets say the minimum is 0 and the maximum is 1 in indexing then you do get 000 up to 111. And that's what I do want to realize for "length" 2 to 10 (or even higher). Well I could use 2, 3 ... loops in loops but well in the beginning I do not know how many are needed. Well maybe I should try to think about a bitmap using an array doing something like if most right position in array is 0 then set it to 1, if it is already 1 then set it to 0 and increase the next position. if this is already 1 then increase the next and set this to 0 etc. :^) meaning 000 +1 => 001 001 + 1=> 010 .... 011 +1 => 100 ... Does anyone of you know a better solution for this? If so please let me know! Because in my example I have to check the bitarray and this task gets bigger for every combination, which is not a good idea concerning performance. :) Thanks! Stephan.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups