| 
    
     |  | ▼ユウキ さん: >おはようございます。
 >論理演算についての質問ですが、文字列の引数を持ち、
 >論理演算NOTした文字列を戻り値として返す関数(NOTモジュール)を
 >作ろうと思うのですがなかなか案が浮かばず知恵を貸してください。
 >
 >目的としたらビット反転などが主です。
 >他にもXOR、OR、ANDなども予定しています。
 >どうかお願いします。
 
 こんばんは。
 
 ビット反転したコードが文字列として成り立つのか知りませんが、
 UNICODEをそのまま反転でよければ、こんな感じでしょうか。
 
 Function Sample1(s As String) As String
 Dim ss As String
 Dim i As Long
 ss = s
 For i = 1 To LenB(s)
 MidB$(ss, i, 1) = ChrB$(Not AscB(MidB$(ss, i, 1)))
 Next
 Sample1 = ss
 End Function
 
 Function Sample2(s As String) As String
 Dim b() As Byte
 Dim i As Long
 b = s
 For i = LBound(b) To UBound(b)
 b(i) = Not b(i)
 Next
 Sample2 = b
 End Function
 
 MsgBox Sample1((Sample1("ハンカク漢字123ABCABC「」")))
 MsgBox Sample2((Sample2("ハンカク漢字123ABCABC「」")))
 MsgBox Sample1((Sample2("ハンカク漢字123ABCABC「」")))
 MsgBox Sample2((Sample1("ハンカク漢字123ABCABC「」")))
 いずれも元に戻ります。
 
 
 |  |