if variable
-
- Posts: 219
- Joined: Tue Oct 27, 2015 4:19 pm
if variable
Good Morning.
I created a variable and I'm trying to write an if but this returning error. The if I'm trying to do so for example:
if (field == 1)
{
"OK";
"true";
}
else
{
"NOK";
"false";
}
Note: I can not use the IIF as within the {} will have multiple values
Att,
Leandro Borges
I created a variable and I'm trying to write an if but this returning error. The if I'm trying to do so for example:
if (field == 1)
{
"OK";
"true";
}
else
{
"NOK";
"false";
}
Note: I can not use the IIF as within the {} will have multiple values
Att,
Leandro Borges
Re: if variable
Hello, Leandro!
If you need use this field in text expression, you can use following way:
Thank you.
If you need use this field in text expression, you can use following way:
Code: Select all
{field == 1 ? "OK" : "NOK"}
-
- Posts: 219
- Joined: Tue Oct 27, 2015 4:19 pm
Re: if variable
Hello, Jan!
Can you explain what that means?
Thank you.
Can you explain what that means?
Thank you.
Re: if variable
Hello, Leandro!
This is standard ternary operation from c#.
[bool-condition] ? [if-true-result] : [if-false-result]
Thank you.
This is standard ternary operation from c#.
[bool-condition] ? [if-true-result] : [if-false-result]
Thank you.
-
- Posts: 219
- Joined: Tue Oct 27, 2015 4:19 pm
Re: if variable
Hello, Jan.
Thank you for explanation.
Now this returning the following error: only assignment, call, increment decrement, await, and new object expressions can be used as a statement.
Note: Example:
field == 1 ? "OK" : "NOK";
field == 2 ? "true" : "false";
Thank you.
Thank you for explanation.
Now this returning the following error: only assignment, call, increment decrement, await, and new object expressions can be used as a statement.
Note: Example:
field == 1 ? "OK" : "NOK";
field == 2 ? "true" : "false";
Thank you.
Re: if variable
Hello, Leandro.
Maybe we don't understand your issue right.
Please, send us a sample report template with more detailed description.
Thank you.
Maybe we don't understand your issue right.
Please, send us a sample report template with more detailed description.
Thank you.
-
- Posts: 219
- Joined: Tue Oct 27, 2015 4:19 pm
Re: if variable
Hello, HighAley.
When only leave a line, the error does not occur.
Example: campo == 1? "OK": "NOK";
When I put the two lines returns the error.
This is a control block that existed in a Crystal report.
if (Vlr_Retido != null)
{
Vlr_Retido;
}
else
{
Vlr_Retido = 0;
}
if (Vlr_Compensa != null)
{
Vlr_Compensa;
}
else
{
Vlr_Compensa = 0;
}
Vlr_Emp == ((Principal.Relação.EMP * Vlr_Base / 100) + (Principal.VLR_AUT * Principal.Relação.AUT / 100)) + Vlr_Acd;
Vlr_Emp == Vlr_Emp - Vlr_Retido;
if (Vlr_Emp < 0 )
{
diferenca == (-1) * Vlr_Emp;
Vlr_Emp == 0;
CompVrRet == False;
}
else
{
CompVrRet == True;
}
if (Vlr_Emp > 1)
{
Vlr_Emp == Vlr_Emp - Vlr_Compensa;
if (Vlr_Emp < 0 )
{
diferenca == (-1) * Vlr_Emp;
Vlr_Emp == 0;
}
else
{
diferenca == 0;
}
}
else
{
if (Vlr_Emp == 0 && Vlr_Compensa > 0)
{
diferenca == Vlr_Compensa;
}
}
When only leave a line, the error does not occur.
Example: campo == 1? "OK": "NOK";
When I put the two lines returns the error.
This is a control block that existed in a Crystal report.
if (Vlr_Retido != null)
{
Vlr_Retido;
}
else
{
Vlr_Retido = 0;
}
if (Vlr_Compensa != null)
{
Vlr_Compensa;
}
else
{
Vlr_Compensa = 0;
}
Vlr_Emp == ((Principal.Relação.EMP * Vlr_Base / 100) + (Principal.VLR_AUT * Principal.Relação.AUT / 100)) + Vlr_Acd;
Vlr_Emp == Vlr_Emp - Vlr_Retido;
if (Vlr_Emp < 0 )
{
diferenca == (-1) * Vlr_Emp;
Vlr_Emp == 0;
CompVrRet == False;
}
else
{
CompVrRet == True;
}
if (Vlr_Emp > 1)
{
Vlr_Emp == Vlr_Emp - Vlr_Compensa;
if (Vlr_Emp < 0 )
{
diferenca == (-1) * Vlr_Emp;
Vlr_Emp == 0;
}
else
{
diferenca == 0;
}
}
else
{
if (Vlr_Emp == 0 && Vlr_Compensa > 0)
{
diferenca == Vlr_Compensa;
}
}
Re: if variable
Hello.
Could you specify where do you use this code?
In the reports you could use any valid C# or VB.NET code.
Thank you.
Could you specify where do you use this code?
In the reports you could use any valid C# or VB.NET code.
Thank you.
-
- Posts: 219
- Joined: Tue Oct 27, 2015 4:19 pm
Re: if variable
Hello, HighAley.
I already solve, thank you.
Can I put the IF more than one condition? Example:
variavel < 0 ? variavel2 == 1; variavel3 == 2; variavel4 == 3; : variavel2 == 4; variavel3 == 5; variavel4 == 6;
Thank you.
I already solve, thank you.
Can I put the IF more than one condition? Example:
variavel < 0 ? variavel2 == 1; variavel3 == 2; variavel4 == 3; : variavel2 == 4; variavel3 == 5; variavel4 == 6;
Thank you.
Re: if variable
Hello.
Sorry, but you did not specify where you use this code.
If you need to set values for different variables you should use if statement. The conditional operator is not for this case.
Also your code is not right because you should use C# or VB.NET language. Which one is set in report properties?
Please, use the right assignment operator.
Thank you.
Sorry, but you did not specify where you use this code.
If you need to set values for different variables you should use if statement. The conditional operator is not for this case.
Also your code is not right because you should use C# or VB.NET language. Which one is set in report properties?
Please, use the right assignment operator.
Thank you.