AW: Darstellung der Operation i AND 2^(j-1)
21.05.2007 08:48:54
ingUR
Hallo,
Hier der Funktions-Code mit ausgabe aller Kombinationen auf das aktive Tabellenblatt zur Darstellung der Wirkung der Operation i AND 2^(j-1)
Function checkValue(Zahl, arWerte)
Dim i&, i1%, j%, n&, m%, sig#, strVal$, strVal1$, strIdx$, strIdx1$
m = UBound(arWerte)
n = 2 ^ m - 1
For i = 1 To n
strVal1 = ""
strIdx = i & " :: "
strIdx1 = i & " :: "
For j = 1 To m
i1 = 2 ^ (j - 1)
If i And 2 ^ (j - 1) Then
strIdx1 = strIdx1 & "[" & i1 & "]"
strIdx = strIdx & "(" & j & ")"
strVal1 = strVal1 & arWerte(j) & "+"
strVal = strVal & arWerte(j) & ";"
sig = sig + arWerte(j)
End If
Next
If sig = Zahl Then
checkValue = strVal & ";" & Zahl
'Exit Function
End If
sig = 0
strVal = ""
If Right(strVal1, 1) = "+" Then strVal1 = Left(strVal1, Len(strVal1) - 1)
Cells(i, 1) = CStr(strVal1)
Cells(i, 2) = "=" & strVal1
Cells(i, 3) = strIdx
Cells(i, 4) = strIdx1
Next
checkValue = "No Match"
End Function
Gruß,
Uwe