type of variable as a result of a result of a control structure
type of variable as a result of a result of a control structure
(OP)
Hi all.
This is a simple question and probably easy to answer me, but I can't find out the solution.
I noted that when I use a control structure (as if then else, for instance), the result has to be in the same type of variable of the result of the else, so how can I change it ?
My problem is: in the following formula, I want to have a result as the percentage y of x, but if x = 0 I want a string as the result of the formula.
Example:
if x <> 0 then
y % x
else
"n. a."
But it doesn't works, because if the first result is a number, Crystal asks for a same type variable in the else part of the control structure.
Anyone can answer me ?
Thanks for helping
Dv
This is a simple question and probably easy to answer me, but I can't find out the solution.
I noted that when I use a control structure (as if then else, for instance), the result has to be in the same type of variable of the result of the else, so how can I change it ?
My problem is: in the following formula, I want to have a result as the percentage y of x, but if x = 0 I want a string as the result of the formula.
Example:
if x <> 0 then
y % x
else
"n. a."
But it doesn't works, because if the first result is a number, Crystal asks for a same type variable in the else part of the control structure.
Anyone can answer me ?
Thanks for helping
Dv
RE: type of variable as a result of a result of a control structure
if x <> 0
then ToText (y % x)
else "n. a."
Another option is to have 2 different fields, one on top of the other, and suppress them based on opposite conditions.
Ken Hamady
http://www.kenhamady.com/
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
RE: type of variable as a result of a result of a control structure
That's the best way.
Dv
RE: type of variable as a result of a result of a control structure
How I can format the number before it becomes a string in the same formula ?
Example:
if x <> 0
then (ToText (y % x) + " % ")
else "n. a."
The result, for instance, is 69,45 %. But I want the result as 69 %. How can I format a number inside a formula without creating another formula ?
The way I now is using the instr and detecting where the . is, but maybe there is a better solution.
Dv
RE: type of variable as a result of a result of a control structure
Totext({field} , 0 ) should work.
Ken Hamady
http://www.kenhamady.com/
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
RE: type of variable as a result of a result of a control structure
Thanks again !