Results 1 to 7 of 7

Thread: Number of possible cases??

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343

    Number of possible cases??

    I have senario that looks like this.

    7 yes/no buttons that can be clicked indvidualy.

    ex.

    button 1 and 2 can be marked, or button 1 or no marks at all.

    How many combinations can this be??

    is it 7^2??? = 7*7 = 49 ??? or ???

    /Smirre
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  2. #2
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    You're on the right track.
    Just think of each button as a position in a binary field of 7 bits.

    Each click would represent a 1, and if it wasn't clicked, then it would represent a 0.
    if you had only 1 button, or 1 bit, then it could have 2 total combinations.
    if you had 2 buttons, or 2 bits, then it could have 4 total combinations.

    so for n buttons, you would have 2^n binary combinations.

    7 buttons gives you 2^7 combinations.

    Would you like a list of them?

    -Lou

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343
    that would be nice.
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  4. #4
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Here's all the combinations your 7 buttons can have:

    VB Code:
    1. Combination #001 = 0000000
    2. Combination #002 = 0000001
    3. Combination #003 = 0000010
    4. Combination #004 = 0000011
    5. Combination #005 = 0000100
    6. Combination #006 = 0000101
    7. Combination #007 = 0000110
    8. Combination #008 = 0000111
    9. Combination #009 = 0001000
    10. Combination #010 = 0001001
    11. Combination #011 = 0001010
    12. Combination #012 = 0001011
    13. Combination #013 = 0001100
    14. Combination #014 = 0001101
    15. Combination #015 = 0001110
    16. Combination #016 = 0001111
    17. Combination #017 = 0010000
    18. Combination #018 = 0010001
    19. Combination #019 = 0010010
    20. Combination #020 = 0010011
    21. Combination #021 = 0010100
    22. Combination #022 = 0010101
    23. Combination #023 = 0010110
    24. Combination #024 = 0010111
    25. Combination #025 = 0011000
    26. Combination #026 = 0011001
    27. Combination #027 = 0011010
    28. Combination #028 = 0011011
    29. Combination #029 = 0011100
    30. Combination #030 = 0011101
    31. Combination #031 = 0011110
    32. Combination #032 = 0011111
    33. Combination #033 = 0100000
    34. Combination #034 = 0100001
    35. Combination #035 = 0100010
    36. Combination #036 = 0100011
    37. Combination #037 = 0100100
    38. Combination #038 = 0100101
    39. Combination #039 = 0100110
    40. Combination #040 = 0100111
    41. Combination #041 = 0101000
    42. Combination #042 = 0101001
    43. Combination #043 = 0101010
    44. Combination #044 = 0101011
    45. Combination #045 = 0101100
    46. Combination #046 = 0101101
    47. Combination #047 = 0101110
    48. Combination #048 = 0101111
    49. Combination #049 = 0110000
    50. Combination #050 = 0110001
    51. Combination #051 = 0110010
    52. Combination #052 = 0110011
    53. Combination #053 = 0110100
    54. Combination #054 = 0110101
    55. Combination #055 = 0110110
    56. Combination #056 = 0110111
    57. Combination #057 = 0111000
    58. Combination #058 = 0111001
    59. Combination #059 = 0111010
    60. Combination #060 = 0111011
    61. Combination #061 = 0111100
    62. Combination #062 = 0111101
    63. Combination #063 = 0111110
    64. Combination #064 = 0111111
    65. Combination #065 = 1000000
    66. Combination #066 = 1000001
    67. Combination #067 = 1000010
    68. Combination #068 = 1000011
    69. Combination #069 = 1000100
    70. Combination #070 = 1000101
    71. Combination #071 = 1000110
    72. Combination #072 = 1000111
    73. Combination #073 = 1001000
    74. Combination #074 = 1001001
    75. Combination #075 = 1001010
    76. Combination #076 = 1001011
    77. Combination #077 = 1001100
    78. Combination #078 = 1001101
    79. Combination #079 = 1001110
    80. Combination #080 = 1001111
    81. Combination #081 = 1010000
    82. Combination #082 = 1010001
    83. Combination #083 = 1010010
    84. Combination #084 = 1010011
    85. Combination #085 = 1010100
    86. Combination #086 = 1010101
    87. Combination #087 = 1010110
    88. Combination #088 = 1010111
    89. Combination #089 = 1011000
    90. Combination #090 = 1011001
    91. Combination #091 = 1011010
    92. Combination #092 = 1011011
    93. Combination #093 = 1011100
    94. Combination #094 = 1011101
    95. Combination #095 = 1011110
    96. Combination #096 = 1011111
    97. Combination #097 = 1100000
    98. Combination #098 = 1100001
    99. Combination #099 = 1100010
    100. Combination #100 = 1100011
    101. Combination #101 = 1100100
    102. Combination #102 = 1100101
    103. Combination #103 = 1100110
    104. Combination #104 = 1100111
    105. Combination #105 = 1101000
    106. Combination #106 = 1101001
    107. Combination #107 = 1101010
    108. Combination #108 = 1101011
    109. Combination #109 = 1101100
    110. Combination #110 = 1101101
    111. Combination #111 = 1101110
    112. Combination #112 = 1101111
    113. Combination #113 = 1110000
    114. Combination #114 = 1110001
    115. Combination #115 = 1110010
    116. Combination #116 = 1110011
    117. Combination #117 = 1110100
    118. Combination #118 = 1110101
    119. Combination #119 = 1110110
    120. Combination #120 = 1110111
    121. Combination #121 = 1111000
    122. Combination #122 = 1111001
    123. Combination #123 = 1111010
    124. Combination #124 = 1111011
    125. Combination #125 = 1111100
    126. Combination #126 = 1111101
    127. Combination #127 = 1111110
    128. Combination #128 = 1111111



    -Lou

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Location
    Kalix, Norrbotten, SWEDEN
    Posts
    343
    how would you choose between these cases??? Should I run a select case or if statements. Each case can have 7 undercases.

    /Smirre
    Visual Basic
    C, C++
    Java
    Access
    SQL Server

    MCP, MCSD

  6. #6
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Heres One way:
    VB Code:
    1. Dim MY_CASES(7) As Boolean
    2. Dim CURR_STATE As Integer
    3.  
    4. Private Sub Command1_Click(Index As Integer)
    5. MY_CASES(Index) = Not (MY_CASES(Index))
    6. EVAL_BUTTS
    7. End Sub
    8. '''I was lazy, so I programmed this to build cmdDoSomething_Click
    9. 'Private Sub Command3_Click()
    10. 'Dim MyFileNum As Integer
    11. 'MyFileNum = FreeFile
    12. 'Open App.Path & "\" & "EVAL_MY_BUTTS.frm" For Append As #MyFileNum
    13. 'Print #MyFileNum, "Private Sub cmdDoSomething_Click()"
    14. 'Print #MyFileNum, "Select Case CURR_STATE"
    15. 'For i = 0 To 127
    16. '    Print #MyFileNum, Chr$(9) & "Case " & i
    17. '    Print #MyFileNum, Chr$(9) & Chr$(9) & "MsgBox " & Chr$(34) & "You are Now in State " & i & Chr$(34)
    18. 'Next i
    19. 'Print #MyFileNum, "End Select"
    20. 'Print #MyFileNum, "End Sub"
    21. 'Close #MyFileNum
    22. 'End Sub
    23.  
    24. Private Sub Form_Load()
    25.     Call EVAL_BUTTS
    26. End Sub
    27. Private Sub EVAL_BUTTS()
    28. CURR_STATE = 0
    29. For i = 0 To 6
    30.     Command1(i).Caption = i & " " & MY_CASES(i)
    31.     If MY_CASES(i) = True Then
    32.         CURR_STATE = CURR_STATE + 2 ^ i
    33.     End If
    34. Next i
    35. Label1.Caption = CURR_STATE
    36. End Sub
    37. Private Sub cmdDoSomething_Click()
    38. Select Case CURR_STATE
    39.         Case 0
    40.                 MsgBox "You are Now in State 0"
    41.         Case 1
    42.                 MsgBox "You are Now in State 1"
    43.         Case 2
    44.                 MsgBox "You are Now in State 2"
    45.         Case 3
    46.                 MsgBox "You are Now in State 3"
    47.         Case 4
    48.                 MsgBox "You are Now in State 4"
    49.         Case 5
    50.                 MsgBox "You are Now in State 5"
    51.         Case 6
    52.                 MsgBox "You are Now in State 6"
    53.         Case 7
    54.                 MsgBox "You are Now in State 7"
    55.         Case 8
    56.                 MsgBox "You are Now in State 8"
    57.         Case 9
    58.                 MsgBox "You are Now in State 9"
    59.         Case 10
    60.                 MsgBox "You are Now in State 10"
    61.         Case 11
    62.                 MsgBox "You are Now in State 11"
    63.         Case 12
    64.                 MsgBox "You are Now in State 12"
    65.         Case 13
    66.                 MsgBox "You are Now in State 13"
    67.         Case 14
    68.                 MsgBox "You are Now in State 14"
    69.         Case 15
    70.                 MsgBox "You are Now in State 15"
    71.         Case 16
    72.                 MsgBox "You are Now in State 16"
    73.         Case 17
    74.                 MsgBox "You are Now in State 17"
    75.         Case 18
    76.                 MsgBox "You are Now in State 18"
    77.         Case 19
    78.                 MsgBox "You are Now in State 19"
    79.         Case 20
    80.                 MsgBox "You are Now in State 20"
    81.         Case 21
    82.                 MsgBox "You are Now in State 21"
    83.         Case 22
    84.                 MsgBox "You are Now in State 22"
    85.         Case 23
    86.                 MsgBox "You are Now in State 23"
    87.         Case 24
    88.                 MsgBox "You are Now in State 24"
    89.         Case 25
    90.                 MsgBox "You are Now in State 25"
    91.         Case 26
    92.                 MsgBox "You are Now in State 26"
    93.         Case 27
    94.                 MsgBox "You are Now in State 27"
    95.         Case 28
    96.                 MsgBox "You are Now in State 28"
    97.         Case 29
    98.                 MsgBox "You are Now in State 29"
    99.         Case 30
    100.                 MsgBox "You are Now in State 30"
    101.         Case 31
    102.                 MsgBox "You are Now in State 31"
    103.         Case 32
    104.                 MsgBox "You are Now in State 32"
    105.         Case 33
    106.                 MsgBox "You are Now in State 33"
    107.         Case 34
    108.                 MsgBox "You are Now in State 34"
    109.         Case 35
    110.                 MsgBox "You are Now in State 35"
    111.         Case 36
    112.                 MsgBox "You are Now in State 36"
    113.         Case 37
    114.                 MsgBox "You are Now in State 37"
    115.         Case 38
    116.                 MsgBox "You are Now in State 38"
    117.         Case 39
    118.                 MsgBox "You are Now in State 39"
    119.         Case 40
    120.                 MsgBox "You are Now in State 40"
    121.         Case 41
    122.                 MsgBox "You are Now in State 41"
    123.         Case 42
    124.                 MsgBox "You are Now in State 42"
    125.         Case 43
    126.                 MsgBox "You are Now in State 43"
    127.         Case 44
    128.                 MsgBox "You are Now in State 44"
    129.         Case 45
    130.                 MsgBox "You are Now in State 45"
    131.         Case 46
    132.                 MsgBox "You are Now in State 46"
    133.         Case 47
    134.                 MsgBox "You are Now in State 47"
    135.         Case 48
    136.                 MsgBox "You are Now in State 48"
    137.         Case 49
    138.                 MsgBox "You are Now in State 49"
    139.         Case 50
    140.                 MsgBox "You are Now in State 50"
    141.         Case 51
    142.                 MsgBox "You are Now in State 51"
    143.         Case 52
    144.                 MsgBox "You are Now in State 52"
    145.         Case 53
    146.                 MsgBox "You are Now in State 53"
    147.         Case 54
    148.                 MsgBox "You are Now in State 54"
    149.         Case 55
    150.                 MsgBox "You are Now in State 55"
    151.         Case 56
    152.                 MsgBox "You are Now in State 56"
    153.         Case 57
    154.                 MsgBox "You are Now in State 57"
    155.         Case 58
    156.                 MsgBox "You are Now in State 58"
    157.         Case 59
    158.                 MsgBox "You are Now in State 59"
    159.         Case 60
    160.                 MsgBox "You are Now in State 60"
    161.         Case 61
    162.                 MsgBox "You are Now in State 61"
    163.         Case 62
    164.                 MsgBox "You are Now in State 62"
    165.         Case 63
    166.                 MsgBox "You are Now in State 63"
    167.         Case 64
    168.                 MsgBox "You are Now in State 64"
    169.         Case 65
    170.                 MsgBox "You are Now in State 65"
    171.         Case 66
    172.                 MsgBox "You are Now in State 66"
    173.         Case 67
    174.                 MsgBox "You are Now in State 67"
    175.         Case 68
    176.                 MsgBox "You are Now in State 68"
    177.         Case 69
    178.                 MsgBox "You are Now in State 69"
    179.         Case 70
    180.                 MsgBox "You are Now in State 70"
    181.         Case 71
    182.                 MsgBox "You are Now in State 71"
    183.         Case 72
    184.                 MsgBox "You are Now in State 72"
    185.         Case 73
    186.                 MsgBox "You are Now in State 73"
    187.         Case 74
    188.                 MsgBox "You are Now in State 74"
    189.         Case 75
    190.                 MsgBox "You are Now in State 75"
    191.         Case 76
    192.                 MsgBox "You are Now in State 76"
    193.         Case 77
    194.                 MsgBox "You are Now in State 77"
    195.         Case 78
    196.                 MsgBox "You are Now in State 78"
    197.         Case 79
    198.                 MsgBox "You are Now in State 79"
    199.         Case 80
    200.                 MsgBox "You are Now in State 80"
    201.         Case 81
    202.                 MsgBox "You are Now in State 81"
    203.         Case 82
    204.                 MsgBox "You are Now in State 82"
    205.         Case 83
    206.                 MsgBox "You are Now in State 83"
    207.         Case 84
    208.                 MsgBox "You are Now in State 84"
    209.         Case 85
    210.                 MsgBox "You are Now in State 85"
    211.         Case 86
    212.                 MsgBox "You are Now in State 86"
    213.         Case 87
    214.                 MsgBox "You are Now in State 87"
    215.         Case 88
    216.                 MsgBox "You are Now in State 88"
    217.         Case 89
    218.                 MsgBox "You are Now in State 89"
    219.         Case 90
    220.                 MsgBox "You are Now in State 90"
    221.         Case 91
    222.                 MsgBox "You are Now in State 91"
    223.         Case 92
    224.                 MsgBox "You are Now in State 92"
    225.         Case 93
    226.                 MsgBox "You are Now in State 93"
    227.         Case 94
    228.                 MsgBox "You are Now in State 94"
    229.         Case 95
    230.                 MsgBox "You are Now in State 95"
    231.         Case 96
    232.                 MsgBox "You are Now in State 96"
    233.         Case 97
    234.                 MsgBox "You are Now in State 97"
    235.         Case 98
    236.                 MsgBox "You are Now in State 98"
    237.         Case 99
    238.                 MsgBox "You are Now in State 99"
    239.         Case 100
    240.                 MsgBox "You are Now in State 100"
    241.         Case 101
    242.                 MsgBox "You are Now in State 101"
    243.         Case 102
    244.                 MsgBox "You are Now in State 102"
    245.         Case 103
    246.                 MsgBox "You are Now in State 103"
    247.         Case 104
    248.                 MsgBox "You are Now in State 104"
    249.         Case 105
    250.                 MsgBox "You are Now in State 105"
    251.         Case 106
    252.                 MsgBox "You are Now in State 106"
    253.         Case 107
    254.                 MsgBox "You are Now in State 107"
    255.         Case 108
    256.                 MsgBox "You are Now in State 108"
    257.         Case 109
    258.                 MsgBox "You are Now in State 109"
    259.         Case 110
    260.                 MsgBox "You are Now in State 110"
    261.         Case 111
    262.                 MsgBox "You are Now in State 111"
    263.         Case 112
    264.                 MsgBox "You are Now in State 112"
    265.         Case 113
    266.                 MsgBox "You are Now in State 113"
    267.         Case 114
    268.                 MsgBox "You are Now in State 114"
    269.         Case 115
    270.                 MsgBox "You are Now in State 115"
    271.         Case 116
    272.                 MsgBox "You are Now in State 116"
    273.         Case 117
    274.                 MsgBox "You are Now in State 117"
    275.         Case 118
    276.                 MsgBox "You are Now in State 118"
    277.         Case 119
    278.                 MsgBox "You are Now in State 119"
    279.         Case 120
    280.                 MsgBox "You are Now in State 120"
    281.         Case 121
    282.                 MsgBox "You are Now in State 121"
    283.         Case 122
    284.                 MsgBox "You are Now in State 122"
    285.         Case 123
    286.                 MsgBox "You are Now in State 123"
    287.         Case 124
    288.                 MsgBox "You are Now in State 124"
    289.         Case 125
    290.                 MsgBox "You are Now in State 125"
    291.         Case 126
    292.                 MsgBox "You are Now in State 126"
    293.         Case 127
    294.                 MsgBox "You are Now in State 127"
    295. End Select
    296. End Sub
    Attached Files Attached Files

  7. #7
    DerFarm
    Guest
    Do you really have that many unique actions? You're going to
    coding till the cows come home.

    Normally, there are some kind of filters that can be applied:

    if bit 7 is set I'm doing this no matter what else happens, if bit 6
    is not set, this happens irrespective of the other things, .....

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