6 Replies - 6853 Views - Last Post: 08 January 2013 - 05:46 PM Rate Topic: -----

#1 Des DC  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 28-December 12

Problem of using if else statement in crystal report vb.net

Posted 07 January 2013 - 09:35 PM

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. But my output is only display the last statement which is
margin & "      " & "R"
.
Can anyone tell me where is my problem/error?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem of using if else statement in crystal report vb.net

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,097
  • Joined: 02-July 08

Re: Problem of using if else statement in crystal report vb.net

Posted 07 January 2013 - 10:13 PM

If the isHalfShare is a boolean the result is 'True' or 'False' and would explain the results your getting. So try to change the '0' and '1' to true and false.
Was This Post Helpful? 0
  • +
  • -

#3 Des DC  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 28-December 12

Re: Problem of using if else statement in crystal report vb.net

Posted 07 January 2013 - 11:05 PM

_HAWK_,the data for my database in {DataNormal.IsHalfShare} is 0,1,2. So i want it to display in word. that is
0->S
1->H
2->R

But now what i get is 10.00 R even my {DataNormal.IsHalfShare} value is 0.
10.00 is the margin value.

_HAWK_,the data for my database in {DataNormal.IsHalfShare} is 0,1,2. So i want it to display in word. that is
0->S
1->H
2->R

But now what i get is 10.00 R even my {DataNormal.IsHalfShare} value is 0.
10.00 is the margin value.
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,097
  • Joined: 02-July 08

Re: Problem of using if else statement in crystal report vb.net

Posted 07 January 2013 - 11:22 PM

Ok, what is the datatype, Int? Try comparing the datatypes directly without converting. CStr({field}) is also available.
Was This Post Helpful? 0
  • +
  • -

#5 Des DC  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 28-December 12

Re: Problem of using if else statement in crystal report vb.net

Posted 07 January 2013 - 11:48 PM

yes. the datatype is Int.
I tried cstr({DataNormal.IsHalfShare})
it will display 10.00 0.00.
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,097
  • Joined: 02-July 08

Re: Problem of using if else statement in crystal report vb.net

Posted 08 January 2013 - 08:03 AM

I am not familiar with Access, but that does not look right - 10.00 0.00 is not an Int or a Float value. If it is just 10.00 then ToText({DataNormal.IsHalfShare}, 0) would give you the whole number - no decimals.
Was This Post Helpful? 0
  • +
  • -

#7 Des DC  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 28-December 12

Re: Problem of using if else statement in crystal report vb.net

Posted 08 January 2013 - 05:46 PM

_HAWK_,my database is MySQL.
Yes. The margin datatype is decimal,but datatype for IsHalfShare is Int.
I'm still try and error to find out my problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1