Decimal_After_Point := Decimal_After_Point - 0.01

Loop

This is how you do it for Basic syntax

Regards

Emre

Solved

Posted on 2004-10-28

Ok... Just a quick one,

i have a series of decimal hours which need to rounded down to the nearest quarter, this is my code that i have in a function:

NumberVar Decimal:= 0;

NumberVar Decimal_After_Point := 0;

//Debug

Decimal := %%%%%VALUE%%%%%

Decimal_After_Point := decimal - int(Decimal);

Decimal := int(decimal);

while Decimal_After_Point <> 0 AND Decimal_After_Point <> 0.25 AND Decimal_After_Point <> 0.5 AND Decimal_After_Point <> 0.75 do

(

Decimal_After_Point := Decimal_After_Point - 0.01

);

Decimal + Decimal_After_Point

Now, i've never done a loop in Crystal reports before, so i was wondering if you guys could tell me where i'm going wrong?

For example, the following are examples and what they should equal:

13.56 = 13.45

2 = 2.00

3.14 = 3.00

56.45 = 56.45

56.44 = 56.30

You get the picture, the initial value will be passed in as 'decimal' and the new value must be returned

i have a series of decimal hours which need to rounded down to the nearest quarter, this is my code that i have in a function:

NumberVar Decimal:= 0;

NumberVar Decimal_After_Point := 0;

//Debug

Decimal := %%%%%VALUE%%%%%

Decimal_After_Point := decimal - int(Decimal);

Decimal := int(decimal);

while Decimal_After_Point <> 0 AND Decimal_After_Point <> 0.25 AND Decimal_After_Point <> 0.5 AND Decimal_After_Point <> 0.75 do

(

Decimal_After_Point := Decimal_After_Point - 0.01

);

Decimal + Decimal_After_Point

Now, i've never done a loop in Crystal reports before, so i was wondering if you guys could tell me where i'm going wrong?

For example, the following are examples and what they should equal:

13.56 = 13.45

2 = 2.00

3.14 = 3.00

56.45 = 56.45

56.44 = 56.30

You get the picture, the initial value will be passed in as 'decimal' and the new value must be returned

15 Comments

Decimal_After_Point := Decimal_After_Point - 0.01

Loop

This is how you do it for Basic syntax

Regards

Emre

And it brings back the Error: The Keyword 'Do' is missing.

Unfortunatly, i need the syntax in CR9 format, hence i'm having the problems in the first place :/

thanks any way tho.

crytsal syntax: looks like c

basic syntax: looks like vb

It is a dropdown box

I have still done the rest of the function in Crystal Syntax anyways, so i still need to know how it's done as above.

Can you toggle the Basic and Crystal syntax by each function or to use Basic syntax do i have to re-write all my other functions?

The original question now stands for 400.

numbervar decimal := 56.44; //add you field here instead of the number

numbervar decimal_val := 0;

select (decimal-int(decimal))

case is < .15 : decimal_val := .0

case is < .30 : decimal_val := .15

case is < .45 : decimal_val := .30

default : decimal_val := .45;

int(decimal) + decimal_val;

Thanks bud, works like a charm.

I am going to award 100 to ebo for pointing out how stupid i am, but you get the 400!

Thanks everyone

If it ain't broke.....

Just get prepared for my next question tomorrow.... :)

By clicking you are agreeing to Experts Exchange's Terms of Use.

This video discusses moving either the default database or any database to a new volume.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**14** Experts available now in Live!