[DEFINE]
Private Const ctInterpretA_ConstVals As String = "0123456789"

[CODE]
Public Function ctInterpretA(ByVal ctString As String) As Boolean
Dim xFinderLeft1 As Long
Dim xFinderRight1 As Long
Dim xLeftString As String
Dim xLong1 As Long
Dim xOldString As String

'Debug.Print "in: " + ctString
ctString = Trim(ctString)
ctInterpretA_Replace ctString, "=>", ">="
ctInterpretA_Replace ctString, "=<", "<="
ctInterpretA_Replace ctString, " ", ""
 

  
ctInterpretA_Replace ctString, "{", "("
If ctString = "" Then Exit Function
ctString = "(" + ctString + ")"

xLong1 = ctInterpretA_iCount(ctString, "(") - ctInterpretA_iCount(ctString, ")")
If xLong1 > 0 Then
  ctString = ctString + String(xLong1, ")")
  Else
  ctString = String(-xLong1, "(") + ctString
  End If

On Error GoTo Er1
Do While ctString <> xOldString
  xOldString = ctString
  xFinderLeft1 = 1
  Do While xFinderLeft1 > 0
    Do
      xFinderLeft1 = InStr(xFinderLeft1, ctString, "(")
      If xFinderLeft1 = 0 Then Exit Do
      xFinderRight1 = xFinderLeft1 + 1
      Do While (xFinderRight1 < Len(ctString) + 1)
        If InStr(ctInterpretA_ConstVals, Mid$(ctString, xFinderRight1, 1)) = 0 Then Exit Do
        xFinderRight1 = xFinderRight1 + 1
        Loop
      If Mid$(ctString, xFinderRight1, 1) <> ")" Then xFinderLeft1 = xFinderRight1: Exit Do
      xLeftString = Mid(ctString, xFinderLeft1 + 1, xFinderRight1 - xFinderLeft1 - 1)
      If InStr(xLeftString, Chr(0)) = 0 Then
        If Not xLeftString = "" Then
          xLeftString = Trim(Str(Val(xLeftString)))
          End If
        ctString = Left(ctString, xFinderLeft1 - 1) + Trim(xLeftString) + Mid(ctString, xFinderRight1 + 1)
        xFinderLeft1 = 0
        Else
        xFinderLeft1 = xFinderLeft1 + 1
        End If
      Exit Do
      Loop
    Loop
  
  ctInterpretA_Replace ctString, "not", Chr(4)
  ctInterpretA_Replace ctString, "and", Chr(3)
  ctInterpretA_Replace ctString, "or", Chr(2)
  ctInterpretA_Replace ctString, "xor", Chr(1)
  ctInterpretA_Replace ctString, "Eqv", Chr(0)

  #If ctInterpretA_CompareVals Then
    ctInterpretA_CheckFor ctString, ">="
    ctInterpretA_CheckFor ctString, "<="
    ctInterpretA_CheckFor ctString, "<>"
    ctInterpretA_Replace ctString, ">=", Chr(5)
    ctInterpretA_Replace ctString, "<=", Chr(6)
    ctInterpretA_Replace ctString, "<>", Chr(7)
    ctInterpretA_CheckFor ctString, "="
    ctInterpretA_CheckFor ctString, "<"
    ctInterpretA_CheckFor ctString, ">"
    ctInterpretA_CheckFor ctString, "|"
    ctInterpretA_Replace ctString, Chr(5), ">="
    ctInterpretA_Replace ctString, Chr(6), "<="
    ctInterpretA_Replace ctString, Chr(7), "<>"
    #End If

  ctInterpretA_ReplaceX ctString, 0, "1001"
  ctInterpretA_ReplaceX ctString, 1, "0110"
  ctInterpretA_ReplaceX ctString, 2, "0111"
  ctInterpretA_ReplaceX ctString, 3, "0001"
  ctInterpretA_ReplaceX ctString, 4, "10"
  ctInterpretA_Replace ctString, Chr(4), "not"
  ctInterpretA_Replace ctString, Chr(3), "and"
  ctInterpretA_Replace ctString, Chr(2), "or"
  ctInterpretA_Replace ctString, Chr(1), "xor"
  ctInterpretA_Replace ctString, Chr(0), "eqv"
  Loop

ctInterpretA = (xOldString = "1")

Rs1:
On Error GoTo 0
'Debug.Print "out: " + xOldString + " / " + ctString
Exit Function

Er1:
Resume Rs1
End Function

Private Sub ctInterpretA_Replace(ByRef ctString As String, ByVal StringToFind As String, ByVal ReplaceString As String)
Dim xLong1 As Long
Dim xLong2 As Long
xLong2 = Len(StringToFind)
Do
  xLong1 = InStr(ctString, StringToFind)
  If xLong1 = 0 Then Exit Do
  ctString = Left(ctString, xLong1 - 1) + ReplaceString + Mid(ctString, xLong1 + xLong2)
  Loop
End Sub

Private Function ctInterpretA_iCount(ByVal bChar As String, ByVal fChar As String) As Long
Dim xLong1 As Long
Do
  xLong1 = InStr(xLong1 + 1&, bChar, fChar)
  If xLong1 = 0& Then Exit Do
  ctInterpretA_iCount = ctInterpretA_iCount + 1&
  Loop
End Function

Private Sub ctInterpretA_ReplaceX(ByRef ctString As String, ByVal FlagToFind As Long, ByVal ReplaceStrings As String)
  Dim xLong1 As Long
  Dim xLong3 As Long
  Dim xLong4 As Long

  Do
    xLong1 = InStr(xLong1 + 1&, ctString, Chr(FlagToFind))
    If xLong1 = 0& Then Exit Do
    If FlagToFind = 4& Then
      If xLong1 < Len(ctString) - 1& Then
        xLong3 = Asc(Mid(ctString, xLong1 + 2&))
      
        If (xLong3 <= FlagToFind Or xLong3 = 41&) And _
           (Mid(ctString, xLong1 + 1&, 1&) = "0" Or Mid(ctString, xLong1 + 1&, 1&) = "1") Then
          If Mid(ctString, xLong1 + 1&, 1&) = "1" Then
            xLong3 = 1&
            Else
            xLong3 = 0&
            End If
          ctString = Left(ctString, xLong1 - 1&) + Mid(ReplaceStrings, xLong3 + 1&, 1&) + Mid(ctString, xLong1 + 2&)
          End If
        End If
      ElseIf xLong1 > 2& And xLong1 < Len(ctString) - 1& Then
      xLong3 = Asc(Mid(ctString, xLong1 - 2&))
      xLong4 = Asc(Mid(ctString, xLong1 + 2&))
      If (xLong3 < FlagToFind Or xLong3 = 40&) And _
         (xLong4 <= FlagToFind Or xLong4 = 41&) And _
         (Mid(ctString, xLong1 - 1&, 1&) = "0" Or Mid(ctString, xLong1 - 1&, 1&) = "1") And _
         (Mid(ctString, xLong1 + 1&, 1&) = "0" Or Mid(ctString, xLong1 + 1&, 1&) = "1") Then
        If Mid(ctString, xLong1 - 1&, 1&) = "0" Then
          xLong3 = 0&
          Else
          xLong3 = 2&
          End If
        If Mid(ctString, xLong1 + 1&, 1&) = "1" Then
          xLong3 = xLong3 + 1&
          End If
        ctString = Left(ctString, xLong1 - 2&) + Mid(ReplaceStrings, xLong3 + 1&, 1&) + Mid(ctString, xLong1 + 2&)
        End If
      End If
    Loop
  End Sub