use variable to set the value in one text to another

Stimulsoft Reports.NET discussion
Post Reply
ddsmith99301
Posts: 52
Joined: Wed May 17, 2017 10:14 pm

use variable to set the value in one text to another

Post by ddsmith99301 »

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
2022-12-21_16-54-26.png
2022-12-21_16-54-26.png (75.16 KiB) Viewed 882 times
2022-12-21_16-50-29.png
2022-12-21_16-50-29.png (14.66 KiB) Viewed 882 times
2022-12-21_16-57-48.png
2022-12-21_16-57-48.png (64.08 KiB) Viewed 882 times
2022-12-21_17-04-17.png
2022-12-21_17-04-17.png (2.98 KiB) Viewed 882 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: use variable to set the value in one text to another

Post by Lech Kulikowski »

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.
ddsmith99301
Posts: 52
Joined: Wed May 17, 2017 10:14 pm

Re: use variable to set the value in one text to another

Post by ddsmith99301 »

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.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: use variable to set the value in one text to another

Post by Lech Kulikowski »

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.
ddsmith99301
Posts: 52
Joined: Wed May 17, 2017 10:14 pm

Re: use variable to set the value in one text to another

Post by ddsmith99301 »

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
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: use variable to set the value in one text to another

Post by Lech Kulikowski »

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.
ddsmith99301
Posts: 52
Joined: Wed May 17, 2017 10:14 pm

Re: use variable to set the value in one text to another

Post by ddsmith99301 »

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?
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: use variable to set the value in one text to another

Post by Lech Kulikowski »

Hello,

Only the same expression.

Thank you.
Post Reply