# C1.Report.FlexReport.Evaluate

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Report_FlexReport_Evaluate_" data-uid="C1.Report.FlexReport.Evaluate*">Evaluate Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Report_FlexReport_Evaluate_" data-uid="C1.Report.FlexReport.Evaluate*"></a>
<h4 id="C1_Report_FlexReport_Evaluate_System_String_" data-uid="C1.Report.FlexReport.Evaluate(System.String)">Evaluate(string)</h4>
<div class="markdown level1 summary"><p>Evaluates a <b>VBScript</b> expression in the current report context.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public object Evaluate(string expression)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Evaluate(expression As String) As Object</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">expression</span></td>
      <td><p>A string with a <b>VBScript</b> expression to be evaluated.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><p>The value of the expression.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Report_FlexReport_Evaluate_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Use this method to evaluate expressions as they would be evaluated while generating a report.
This can be useful in designer-type applications, to provide an "Immediate Window" where users can test 
expressions.</p>
<p>If the <b>expression</b> string contains invalid syntax or causes an evaluation error, the control 
raises the <a class="xref" href="C1.Report.FlexReport.ReportError.html">ReportError</a> event. In this case, the <i>Handled</i> parameter of the event
is set to true, so the exception is ignored by default.</p>
</div>
<h5 id="C1_Report_FlexReport_Evaluate_System_String__examples">Examples</h5>
<p>Expressions may contain simple <b>VBScript</b> expressions such as:</p>
<pre><code class="lang-csharp">Console.WriteLine(_c1r.Evaluate("2+2"));
  4
Console.WriteLine(_c1r.Evaluate(" \"A\" &amp; \"B\" ");
  AB</code></pre>
<p>Expressions may also contain references to the <b>Report</b> object and all its sub-objects. For example:</p>
<pre><code class="lang-csharp">Console.WriteLine(_c1r.Evaluate("Report.DataSource.RecordSource"));
  SELECT * FROM Employees
Console.WriteLine(_c1r.Evaluate("Report.DataSource.Recordset.Fields.Count"));
  7
Console.WriteLine(_c1r.Evaluate("Report.Fields(0).Name"));
  FirstNameField</code></pre>
<p>Finally, data fields, <a class="xref" href="C1.Report.Field.html">Field</a>, and <a class="xref" href="C1.Report.Section.html">Section</a> objects may be referenced directly by name.</p>
<pre><code class="lang-csharp">Console.WriteLine(_c1r.Evaluate("FirstNameField.Value"));
  Andrew
Console.WriteLine(_c1r.Evaluate("CategoryName"));
  Beverages</code></pre>



<a id="C1_Report_FlexReport_Evaluate_" data-uid="C1.Report.FlexReport.Evaluate*"></a>
<h4 id="C1_Report_FlexReport_Evaluate_System_String_C1_Report_IReportScriptContext_" data-uid="C1.Report.FlexReport.Evaluate(System.String,C1.Report.IReportScriptContext)">Evaluate(string, IReportScriptContext)</h4>
<div class="markdown level1 summary"><p>Evaluates a <b>VBScript</b> expression.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public object Evaluate(string expression, IReportScriptContext context)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Evaluate(expression As String, context As IReportScriptContext) As Object</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">expression</span></td>
      <td><p>A string with a <b>VBScript</b> expression to be evaluated.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Report.IReportScriptContext.html">IReportScriptContext</a></td>
      <td><span class="parametername">context</span></td>
      <td><p><a class="xref" href="C1.Report.IReportScriptContext.html">IReportScriptContext</a> interface used to obtain objects available in expression.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><p>The value of the expression.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
