Boolean Expression Evaluator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Workaholic

    Boolean Expression Evaluator

    Hi,

    I have an application which is reading a boolean expression from an
    external file into a string. The string will equal something like "1 =
    1" or "0 = 1". I need to be able to evaluate the boolean answer, but
    have found that using command such as IIF, CBOOL, etc, will not accept
    the string datatype. There seem to be lots of maths expression
    evaluation tools and examples, but my need seems very simple and I'm
    wondering if there is an easier way? If I could use something simple
    such as IIF(<string>,<t rue>,<false>) it would be ideal

    Thanks for your help
  • sstory

    #2
    Re: Boolean Expression Evaluator

    Here is an article on making one in C#. You could do the same from VB.NET.


    Here is another. So it appears you can cheat by using JScript's eval method:


    "Workaholic " <workaholicme@h otmail.comwrote in message
    news:8d8fb2b5-a730-4cbb-a8a8-7f7875e307f8@2g 2000hsn.googleg roups.com...
    Hi,
    >
    I have an application which is reading a boolean expression from an
    external file into a string. The string will equal something like "1 =
    1" or "0 = 1". I need to be able to evaluate the boolean answer, but
    have found that using command such as IIF, CBOOL, etc, will not accept
    the string datatype. There seem to be lots of maths expression
    evaluation tools and examples, but my need seems very simple and I'm
    wondering if there is an easier way? If I could use something simple
    such as IIF(<string>,<t rue>,<false>) it would be ideal
    >
    Thanks for your help

    Comment

    • Workaholic

      #3
      Re: Boolean Expression Evaluator

      Thanks for this reply sstory. I looked at the example you suggested at
      http://www.odetocode.com/Code/80.aspx, and successfully converted this
      to VB with some help from this site http://labs.developerfusion.co.uk/co...arp-to-vb.aspx

      The code now successfully resolves "1>2" to false, or "1<2" to true,
      but errors on "1=1". I will add a post on the OdeToCode site to see if
      somebody can help

      Thanks again

      Comment

      Working...