# Quick Start - Using VBAEngine

## Content



This quick start guides you through a process of creating an application that uses VBAEngine, binds CalcEngine to data, assign expression to it and evaluate result.

Complete the following steps to see how the result is calculated based on the assigned expression using CalcEngine.

### Create Data Source

Create a class, say Product, to generate data collection for CalcEngine.

```csharp
public class Product
{
public int Id { get; set; }
public String Name { get; set; }
public int Qnt { get; set; }
public double Price { get; set; }
}
```


> type=note
> Note that, VBAEngine is the default engine for CalEngine. Hence, you need not pass VBAEngine as a parameter in the C1CalcEngine constructor while initializing an instance of C1CalcEngine.

### Bind CalcEngine to Data Source

1.  Initialize an instance of [C1CalcEngine](/componentone/api/services/online-calcengine/dotnet-standard-api/C1.CalcEngine/C1.CalcEngine.C1CalcEngine.html) class using the following code.<br />
    
    ```csharp
    //Initialize C1CalcEngine instance of type VBAEngine
    C1CalcEngine _calcEngine = new C1CalcEngine();
    ```
    
2.  Create an array of type **Product** and bind it to the CalcEngine using [DataSource](/componentone/api/services/online-calcengine/dotnet-standard-api/C1.CalcEngine/C1.CalcEngine.C1CalcEngine.DataSource.html) property of the **C1CalcEngine** class.<br />
    
    ```csharp
    //Bind C1CalcEngine to data collection
    var collection = new Product[]
    {
    new Product {Id=1, Name = "Chai", Qnt = 18, Price = 18.1 },
    new Product {Id=2, Name = "Pavlova", Qnt = 11, Price = 17.45 },
    new Product { Id=3, Name= "Sir Rodney's Marmalade", Qnt = 1,
    Price = 40 },
    new Product { Id=4, Name= "Ipoh Coffee", Qnt = 10, Price = 14.0
    },
    new Product { Id=5, Name="Mascarpone Fabioli", Qnt = 16, Price =
    32.0 },
    new Product { Id=6, Name= "Schoggi Schokolade", Qnt = 12, Price
    = 43.9 },
    };
    _calcEngine.DataSource = collection;
    ```
    

### Assign Expression and Evaluate Result

Assign a VBA syntax expression to the CalcEngine using the [Expression](/componentone/api/services/online-calcengine/dotnet-standard-api/C1.CalcEngine/C1.CalcEngine.C1CalcEngine.Expression.html) property and invoke the [TryEvaluate](/componentone/api/services/online-calcengine/dotnet-standard-api/C1.CalcEngine/C1.CalcEngine.C1CalcEngine.TryEvaluate.html) method to calculate the expression.

```csharp
//Assign the expression to be calculated to C1CalcEngine
_calcEngine.Expression = "=Sum([Qnt]*[Price])";
//Invoke the TryEvaluate method of C1CalcEngine to calculate the expression
var res = _calcEngine.TryEvaluate(out object result) ? result.ToString() :
_calcEngine.GetErrors().FirstOrDefault()?.FullMessage ?? "";//To Evaluate the
expression
//Display the expression evaluation result
Console.WriteLine("Total Price of the Products: " + res);
```