use variable to set the value in one text to another
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
use variable to set the value in one text to another
This is kind of urgent. I know they all are.
I know this question has been answered before but the answers don't make sense. I have one text box that I want to set the value of another text box. Seems simple. Here is what I tried.
Set text in B3 to 214,962.92
Create a variable VC3
Set text in C3 from variable VC3
In the Preview it shows {B3.Text} instead of 214,962.92
I know this question has been answered before but the answers don't make sense. I have one text box that I want to set the value of another text box. Seems simple. Here is what I tried.
Set text in B3 to 214,962.92
Create a variable VC3
Set text in C3 from variable VC3
In the Preview it shows {B3.Text} instead of 214,962.92
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: use variable to set the value in one text to another
Hello,
During the report, rendering exists two instances of each component (minimum two instances). One instance - component in the report template. Second instance - component which created the rendered report. During the creation of the second instance, the report engine calculates expressions and writes them to the second instance. When you write code like this:
Text23.Text = "test";
you call instances from the report template which does not contain calculated values from expressions.
You can:
1. Instead of "{Text1.TextValue}" expression using the same expression as in Text1.Text property, or
2. Use variables. In this case, you can calculate the value in the variable, and then use this variable in expressions.
Thank you.
During the report, rendering exists two instances of each component (minimum two instances). One instance - component in the report template. Second instance - component which created the rendered report. During the creation of the second instance, the report engine calculates expressions and writes them to the second instance. When you write code like this:
Text23.Text = "test";
you call instances from the report template which does not contain calculated values from expressions.
You can:
1. Instead of "{Text1.TextValue}" expression using the same expression as in Text1.Text property, or
2. Use variables. In this case, you can calculate the value in the variable, and then use this variable in expressions.
Thank you.
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
Re: use variable to set the value in one text to another
Thanks for your reply. I have seen this post before, but I still don't know how to do it. Please give me an example of how to use the variable.
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: use variable to set the value in one text to another
Hello,
On your screenshot in the B3 text component is a static value, instead of the "B3.Text" you should use that static value in the variable or in the text component.
Thank you.
On your screenshot in the B3 text component is a static value, instead of the "B3.Text" you should use that static value in the variable or in the text component.
Thank you.
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
Re: use variable to set the value in one text to another
I didn't explain the objective well. I would like to use an expression in B2 to return some value. Then I want to use that returned value in an expression in another text component (C3 in this example).
Set text in B3 with an expression that returns some numeric value
Create a variable VC3
set the value returned from B3 to the variable VC3
Set text in C3 from variable VC3 or use the variable in an expression in C3
Ultimately, the goal is to use the results of expressions in text components in expressions in other text components.
Excel does this something like.
use some formula in B2. a + b where a = 16 and b = 14
use some formula in B3. B2 / 3
C3 uses B3/B2 to return a value .3
Set text in B3 with an expression that returns some numeric value
Create a variable VC3
set the value returned from B3 to the variable VC3
Set text in C3 from variable VC3 or use the variable in an expression in C3
Ultimately, the goal is to use the results of expressions in text components in expressions in other text components.
Excel does this something like.
use some formula in B2. a + b where a = 16 and b = 14
use some formula in B3. B2 / 3
C3 uses B3/B2 to return a value .3
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: use variable to set the value in one text to another
Hello,
Ok, in the B2 you use some expression like: {b1+b2+b3}, in the B3 you want to use that value, in that case, you can use the same expression in the B3: {b1+b2+b3}
Thank you.
Ok, in the B2 you use some expression like: {b1+b2+b3}, in the B3 you want to use that value, in that case, you can use the same expression in the B3: {b1+b2+b3}
Thank you.
-
- Posts: 52
- Joined: Wed May 17, 2017 10:14 pm
Re: use variable to set the value in one text to another
So, what you are saying is there is no way to use the results of an expression in one text component (B2) in another text component (B3) without using the same expression?
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: use variable to set the value in one text to another
Hello,
Only the same expression.
Thank you.
Only the same expression.
Thank you.