We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.

# Variables within a formula

#### Replies:

56387 Feb 14,2007 12:06 PM UTC Feb 14,2007 01:30 PM UTC WinForms 1
 Subscribe to this post Tags: Calculate
Henrik Brinch
Asked On February 14, 2007 12:06 PM UTC

Dear Sirs,

Is there any way I can add/set the index (business objects) from within a formula.

E.g. I want to be able to set a variable [A] to a value from within the formula, set a variable [B] and then set a [C] with the sum of [A] and [B] - all this from within the formulas.

I've tried making my own functions, SetVar that adds to the indexer

SetVar(A,10)
SetVar(B,20)

[A]+[B] gives 30 ... so that works...

But

SetVar(C, [A]+[B])
[C]

Gives:

bA1A2ab ??????

What do I do?

Best Regards,
- Henrik Brinch

Replied On February 14, 2007 01:30 PM UTC

bA1A2ab is the parsed version of [A]+[B]. If you evaluate bA1A2ab (by calling calcquick.Engine.ComputeValue("bA1A2ab"), you should get the sum of 10 and 20.

You did not post your SetVar, but if you somehow do the equivalent of

calcQuick["C"] = "=[A]+[B]";

then I think it should work. Here is a snippet that works as expected for me inside a button handler.
`Syncfusion.Calculate.CalcQuick q = new Syncfusion.Calculate.CalcQuick(true);q["A"] = "10";q["B"] = "20";q["C"] = "=[A]+[B]";this.label1.Text = q["C"]; 'shows 30`

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.