Reputation: 105
I have two text fields in crystal report, textA
and textB
.
What if I wanted through the formula editor (not via c# code) set a third field called textTot = textA + textB
.
What is the correct crystal report syntax?
Thanks a lot.
Upvotes: 1
Views: 2430
Reputation: 2437
The simplist formula is: ToNumber({TableName.TextA}) + ToNumber({TableName.TextB})
.
However, it would be a good idea to first test whether the data is numeric (to avoid a runtime error):
Local NumberVar numericA;
Local NumberVar numericB;
If IsNumeric(Trim({textA}))
Then numericA = ToNumber(Trim({textA}))
Else numericA = 0;
If IsNumeric(Trim({textB}))
Then numericB = ToNumber(Trim({textB}))
Else numericB = 0;
numericA + numericB;
Upvotes: 3