Click here to Skip to main content
13,459,139 members
Rate this:
Please Sign up or sign in to vote.
Hi all,
I facing a problem while using if else statement.
here my code
stringvar halfshare := ToText({DataNormal.IsHalfShare});
stringvar margin := ToText({DataNormal.Margin});

if halfshare = "0" then
margin & "      " & "S"
else if halfshare = "1" then
margin & "      " & "H"
margin & "      " & "R";

I have declaring the variable as above in the formula bar of crystal report. But my output is only display the last statement which is
margin & "      " & "R"
Can anyone tell me where is my problem/error?
Posted 7-Jan-13 17:39pm
Aarti Meswania 7-Jan-13 23:58pm
comment if-else portion and just print
halfshare variable
it will always having value Except 0 and 1 that's why it always goes in last else part and printing
margin & " " & "R"
Those are not statements, but expressions. Do you know the difference? :-) There are no statements, which is wrong.
Des DC 8-Jan-13 1:01am
Aarti Meswania,my database information is saved as 0,1 or 2 in {DataNormal.IsHalfShare}. so i want the system to differentiate it.
Des DC 8-Jan-13 1:01am
Sergey Alexandrovich Kryukov,really?because my database is saved as 0,1,2 in {DataNormal.IsHalfShare}.so i wish to display it in S,H or R.
thomasriley 9-Jan-13 8:52am
replace the last else with - OrElse
Des DC 9-Jan-13 19:59pm
sorry for late.
I solved my problem.
My solution is convert it into char first before retrieve into crystal report. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180323.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100