Click here to Skip to main content
12,950,084 members (61,640 online)
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"
else 
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
Des DC533
Comments
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"
value
   
Those are not statements, but expressions. Do you know the difference? :-) There are no statements, which is wrong.
—SA
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
   
Hi,guys.
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
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2017
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