combit List & Label 29 - .NET Help
combit.Reporting Namespace / ExpressionEvaluator Class / Evaluate Method

The formula for evaluating.



In This Topic
    Evaluate Method
    In This Topic

    The formula is passed to the Evaluate method, which returns the result as an object. Now, you can carry out an easy type conversion according to the data type. The sample listing shows how to call the class. The current date is passed as a variable. List & Label.s designer function, AddWeeks, adds two weeks to this date. The result is displayed in a MessageBox.

    Syntax
    'Declaration
     
    
    Public Function Evaluate( _
       ByVal expression As String _
    ) As Object
    public object Evaluate( 
       string expression
    )
    public:
    Object^ Evaluate( 
       String^ expression
    ) 

    Parameters

    expression

    The formula for evaluating.

    Example
    ...
    ExpressionEvaluator eval = new ExpressionEvaluator();
    eval.Variables.Add("date", DateTime.Now);
    
    DateTime newDate = (DateTime)eval.Evaluate("AddWeeks(date, 2)");
    
    MessageBox.Show(newDate.ToString());
    ... 
    
    Requirements

    Platforms: Windows 10 (Version 21H2 - 23H2), Windows 11 (21H2 - 22H2), Windows Server 2016 - 2022
    .NET: .NET Framework 4.8, .NET 6, .NET 7, .NET 8

    See Also