|
Public Sub ensyu_4()
Dim Atai As Long
Dim RIdx As Long
RIdx = 0
For Atai = 1 To 40
'0
If ((RIdx And 1) = 0) Then
RIdx = RIdx Or Atai
'1bit立・2bit空
ElseIf ((RIdx And 1) = 1) And ((RIdx And 2) = 0) Then
RIdx = RIdx Xor 3
RIdx = RIdx Or Atai
'1bit立・2bit立・3bit空
ElseIf ((RIdx And 1) = 1) And ((RIdx And 2) = 2) And ((RIdx And 4) = 0) Then
RIdx = RIdx Xor 3
RIdx = RIdx Or Atai
'1bit立・2bit立・3bit立・4bit空
ElseIf ((RIdx And 1) = 1) And ((RIdx And 2) = 2) And ((RIdx And 4) = 4) And ((RIdx And 8) = 0) Then
RIdx = RIdx Xor 7
RIdx = RIdx Or Atai
End If
Cells(Atai, 1).Value = RIdx
Next Atai
End Sub
こんな風に書いてみたのですが・・・
力技でしょうか?
また、4bitまでしか確認できないので
上位・下位を分けて考えたいと思っているのですが
RIdx Mod 16では分けることはできないのでしょうか?
|
|