Click to See Complete Forum and Search --> : Number of possible cases??
Smirre
Jan 28th, 2002, 09:15 AM
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
NotLKH
Jan 28th, 2002, 09:54 AM
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
Smirre
Jan 28th, 2002, 09:57 AM
that would be nice.
NotLKH
Jan 28th, 2002, 10:24 AM
Here's all the combinations your 7 buttons can have:
Combination #001 = 0000000
Combination #002 = 0000001
Combination #003 = 0000010
Combination #004 = 0000011
Combination #005 = 0000100
Combination #006 = 0000101
Combination #007 = 0000110
Combination #008 = 0000111
Combination #009 = 0001000
Combination #010 = 0001001
Combination #011 = 0001010
Combination #012 = 0001011
Combination #013 = 0001100
Combination #014 = 0001101
Combination #015 = 0001110
Combination #016 = 0001111
Combination #017 = 0010000
Combination #018 = 0010001
Combination #019 = 0010010
Combination #020 = 0010011
Combination #021 = 0010100
Combination #022 = 0010101
Combination #023 = 0010110
Combination #024 = 0010111
Combination #025 = 0011000
Combination #026 = 0011001
Combination #027 = 0011010
Combination #028 = 0011011
Combination #029 = 0011100
Combination #030 = 0011101
Combination #031 = 0011110
Combination #032 = 0011111
Combination #033 = 0100000
Combination #034 = 0100001
Combination #035 = 0100010
Combination #036 = 0100011
Combination #037 = 0100100
Combination #038 = 0100101
Combination #039 = 0100110
Combination #040 = 0100111
Combination #041 = 0101000
Combination #042 = 0101001
Combination #043 = 0101010
Combination #044 = 0101011
Combination #045 = 0101100
Combination #046 = 0101101
Combination #047 = 0101110
Combination #048 = 0101111
Combination #049 = 0110000
Combination #050 = 0110001
Combination #051 = 0110010
Combination #052 = 0110011
Combination #053 = 0110100
Combination #054 = 0110101
Combination #055 = 0110110
Combination #056 = 0110111
Combination #057 = 0111000
Combination #058 = 0111001
Combination #059 = 0111010
Combination #060 = 0111011
Combination #061 = 0111100
Combination #062 = 0111101
Combination #063 = 0111110
Combination #064 = 0111111
Combination #065 = 1000000
Combination #066 = 1000001
Combination #067 = 1000010
Combination #068 = 1000011
Combination #069 = 1000100
Combination #070 = 1000101
Combination #071 = 1000110
Combination #072 = 1000111
Combination #073 = 1001000
Combination #074 = 1001001
Combination #075 = 1001010
Combination #076 = 1001011
Combination #077 = 1001100
Combination #078 = 1001101
Combination #079 = 1001110
Combination #080 = 1001111
Combination #081 = 1010000
Combination #082 = 1010001
Combination #083 = 1010010
Combination #084 = 1010011
Combination #085 = 1010100
Combination #086 = 1010101
Combination #087 = 1010110
Combination #088 = 1010111
Combination #089 = 1011000
Combination #090 = 1011001
Combination #091 = 1011010
Combination #092 = 1011011
Combination #093 = 1011100
Combination #094 = 1011101
Combination #095 = 1011110
Combination #096 = 1011111
Combination #097 = 1100000
Combination #098 = 1100001
Combination #099 = 1100010
Combination #100 = 1100011
Combination #101 = 1100100
Combination #102 = 1100101
Combination #103 = 1100110
Combination #104 = 1100111
Combination #105 = 1101000
Combination #106 = 1101001
Combination #107 = 1101010
Combination #108 = 1101011
Combination #109 = 1101100
Combination #110 = 1101101
Combination #111 = 1101110
Combination #112 = 1101111
Combination #113 = 1110000
Combination #114 = 1110001
Combination #115 = 1110010
Combination #116 = 1110011
Combination #117 = 1110100
Combination #118 = 1110101
Combination #119 = 1110110
Combination #120 = 1110111
Combination #121 = 1111000
Combination #122 = 1111001
Combination #123 = 1111010
Combination #124 = 1111011
Combination #125 = 1111100
Combination #126 = 1111101
Combination #127 = 1111110
Combination #128 = 1111111
:)
-Lou
Smirre
Jan 28th, 2002, 12:11 PM
how would you choose between these cases??? Should I run a select case or if statements. Each case can have 7 undercases.
/Smirre
NotLKH
Jan 28th, 2002, 12:34 PM
Heres One way:
Dim MY_CASES(7) As Boolean
Dim CURR_STATE As Integer
Private Sub Command1_Click(Index As Integer)
MY_CASES(Index) = Not (MY_CASES(Index))
EVAL_BUTTS
End Sub
'''I was lazy, so I programmed this to build cmdDoSomething_Click
'Private Sub Command3_Click()
'Dim MyFileNum As Integer
'MyFileNum = FreeFile
'Open App.Path & "\" & "EVAL_MY_BUTTS.frm" For Append As #MyFileNum
'Print #MyFileNum, "Private Sub cmdDoSomething_Click()"
'Print #MyFileNum, "Select Case CURR_STATE"
'For i = 0 To 127
' Print #MyFileNum, Chr$(9) & "Case " & i
' Print #MyFileNum, Chr$(9) & Chr$(9) & "MsgBox " & Chr$(34) & "You are Now in State " & i & Chr$(34)
'Next i
'Print #MyFileNum, "End Select"
'Print #MyFileNum, "End Sub"
'Close #MyFileNum
'End Sub
Private Sub Form_Load()
Call EVAL_BUTTS
End Sub
Private Sub EVAL_BUTTS()
CURR_STATE = 0
For i = 0 To 6
Command1(i).Caption = i & " " & MY_CASES(i)
If MY_CASES(i) = True Then
CURR_STATE = CURR_STATE + 2 ^ i
End If
Next i
Label1.Caption = CURR_STATE
End Sub
Private Sub cmdDoSomething_Click()
Select Case CURR_STATE
Case 0
MsgBox "You are Now in State 0"
Case 1
MsgBox "You are Now in State 1"
Case 2
MsgBox "You are Now in State 2"
Case 3
MsgBox "You are Now in State 3"
Case 4
MsgBox "You are Now in State 4"
Case 5
MsgBox "You are Now in State 5"
Case 6
MsgBox "You are Now in State 6"
Case 7
MsgBox "You are Now in State 7"
Case 8
MsgBox "You are Now in State 8"
Case 9
MsgBox "You are Now in State 9"
Case 10
MsgBox "You are Now in State 10"
Case 11
MsgBox "You are Now in State 11"
Case 12
MsgBox "You are Now in State 12"
Case 13
MsgBox "You are Now in State 13"
Case 14
MsgBox "You are Now in State 14"
Case 15
MsgBox "You are Now in State 15"
Case 16
MsgBox "You are Now in State 16"
Case 17
MsgBox "You are Now in State 17"
Case 18
MsgBox "You are Now in State 18"
Case 19
MsgBox "You are Now in State 19"
Case 20
MsgBox "You are Now in State 20"
Case 21
MsgBox "You are Now in State 21"
Case 22
MsgBox "You are Now in State 22"
Case 23
MsgBox "You are Now in State 23"
Case 24
MsgBox "You are Now in State 24"
Case 25
MsgBox "You are Now in State 25"
Case 26
MsgBox "You are Now in State 26"
Case 27
MsgBox "You are Now in State 27"
Case 28
MsgBox "You are Now in State 28"
Case 29
MsgBox "You are Now in State 29"
Case 30
MsgBox "You are Now in State 30"
Case 31
MsgBox "You are Now in State 31"
Case 32
MsgBox "You are Now in State 32"
Case 33
MsgBox "You are Now in State 33"
Case 34
MsgBox "You are Now in State 34"
Case 35
MsgBox "You are Now in State 35"
Case 36
MsgBox "You are Now in State 36"
Case 37
MsgBox "You are Now in State 37"
Case 38
MsgBox "You are Now in State 38"
Case 39
MsgBox "You are Now in State 39"
Case 40
MsgBox "You are Now in State 40"
Case 41
MsgBox "You are Now in State 41"
Case 42
MsgBox "You are Now in State 42"
Case 43
MsgBox "You are Now in State 43"
Case 44
MsgBox "You are Now in State 44"
Case 45
MsgBox "You are Now in State 45"
Case 46
MsgBox "You are Now in State 46"
Case 47
MsgBox "You are Now in State 47"
Case 48
MsgBox "You are Now in State 48"
Case 49
MsgBox "You are Now in State 49"
Case 50
MsgBox "You are Now in State 50"
Case 51
MsgBox "You are Now in State 51"
Case 52
MsgBox "You are Now in State 52"
Case 53
MsgBox "You are Now in State 53"
Case 54
MsgBox "You are Now in State 54"
Case 55
MsgBox "You are Now in State 55"
Case 56
MsgBox "You are Now in State 56"
Case 57
MsgBox "You are Now in State 57"
Case 58
MsgBox "You are Now in State 58"
Case 59
MsgBox "You are Now in State 59"
Case 60
MsgBox "You are Now in State 60"
Case 61
MsgBox "You are Now in State 61"
Case 62
MsgBox "You are Now in State 62"
Case 63
MsgBox "You are Now in State 63"
Case 64
MsgBox "You are Now in State 64"
Case 65
MsgBox "You are Now in State 65"
Case 66
MsgBox "You are Now in State 66"
Case 67
MsgBox "You are Now in State 67"
Case 68
MsgBox "You are Now in State 68"
Case 69
MsgBox "You are Now in State 69"
Case 70
MsgBox "You are Now in State 70"
Case 71
MsgBox "You are Now in State 71"
Case 72
MsgBox "You are Now in State 72"
Case 73
MsgBox "You are Now in State 73"
Case 74
MsgBox "You are Now in State 74"
Case 75
MsgBox "You are Now in State 75"
Case 76
MsgBox "You are Now in State 76"
Case 77
MsgBox "You are Now in State 77"
Case 78
MsgBox "You are Now in State 78"
Case 79
MsgBox "You are Now in State 79"
Case 80
MsgBox "You are Now in State 80"
Case 81
MsgBox "You are Now in State 81"
Case 82
MsgBox "You are Now in State 82"
Case 83
MsgBox "You are Now in State 83"
Case 84
MsgBox "You are Now in State 84"
Case 85
MsgBox "You are Now in State 85"
Case 86
MsgBox "You are Now in State 86"
Case 87
MsgBox "You are Now in State 87"
Case 88
MsgBox "You are Now in State 88"
Case 89
MsgBox "You are Now in State 89"
Case 90
MsgBox "You are Now in State 90"
Case 91
MsgBox "You are Now in State 91"
Case 92
MsgBox "You are Now in State 92"
Case 93
MsgBox "You are Now in State 93"
Case 94
MsgBox "You are Now in State 94"
Case 95
MsgBox "You are Now in State 95"
Case 96
MsgBox "You are Now in State 96"
Case 97
MsgBox "You are Now in State 97"
Case 98
MsgBox "You are Now in State 98"
Case 99
MsgBox "You are Now in State 99"
Case 100
MsgBox "You are Now in State 100"
Case 101
MsgBox "You are Now in State 101"
Case 102
MsgBox "You are Now in State 102"
Case 103
MsgBox "You are Now in State 103"
Case 104
MsgBox "You are Now in State 104"
Case 105
MsgBox "You are Now in State 105"
Case 106
MsgBox "You are Now in State 106"
Case 107
MsgBox "You are Now in State 107"
Case 108
MsgBox "You are Now in State 108"
Case 109
MsgBox "You are Now in State 109"
Case 110
MsgBox "You are Now in State 110"
Case 111
MsgBox "You are Now in State 111"
Case 112
MsgBox "You are Now in State 112"
Case 113
MsgBox "You are Now in State 113"
Case 114
MsgBox "You are Now in State 114"
Case 115
MsgBox "You are Now in State 115"
Case 116
MsgBox "You are Now in State 116"
Case 117
MsgBox "You are Now in State 117"
Case 118
MsgBox "You are Now in State 118"
Case 119
MsgBox "You are Now in State 119"
Case 120
MsgBox "You are Now in State 120"
Case 121
MsgBox "You are Now in State 121"
Case 122
MsgBox "You are Now in State 122"
Case 123
MsgBox "You are Now in State 123"
Case 124
MsgBox "You are Now in State 124"
Case 125
MsgBox "You are Now in State 125"
Case 126
MsgBox "You are Now in State 126"
Case 127
MsgBox "You are Now in State 127"
End Select
End Sub
DerFarm
Jan 28th, 2002, 12:36 PM
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, .....
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.