Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Evaluating string expressions in VB - help!


Message #1 by "Peter Hall" <peterhall@b...> on Sat, 17 Mar 2001 17:46:21
There was a correction in below function in the sample code.
In both Select Cases , I was using opr1, instead of opr1 and opr2.


Private Function CompareOperator(opr1 As String, opr2 As String) As Boolean
    Dim iValue As Integer
    Dim jValue As Integer
    Select Case opr1
        Case "*"
             iValue = 5
        Case "+", "-"
            iValue = 4
    End Select
    
    Select Case opr2
        Case "*"
             jValue = 5
        Case "+", "-"
            jValue = 4
    End Select
    
    If iValue > jValue Then
        CompareOperator = True
    Else
        CompareOperator = False
    End If
    
    
End Function




Liju


> I am rewriting the front-end for a legacy database which uses the Access 
> eval expression to evaluate strings such as "32 + 15 + (2*22)", and 
return 
> a result of 91.
> 
> Can anybody suggest how to do this in VB6 please? (Preferably without 
> writing a full parser!) 
> 
> I'm not allowed to assume that the users will have Access installed, so 
> can't just set a reference to the Access object library. It was 
suggested 
> that I use the eval feature of the Microsoft script control 1.0, but 
when 
> I try the code I just get told that the scripting language hasn't been 
set.
> 
> Thanks
> Peter Hall

  Return to Index