Hi,
This routine seems to work wonderfully on windows 7 .. but windows 10 it fails every now and then
GFCT# = VAL(GFCT$)
GFOT# = VAL(GFOT$)
IF GFCT# = 0 OR (GFCT# + GFOT#) = 0 THEN
calc3# = 0.00
ELSE
calc# = (GFCT# / (GFCT# + GFOT#)) * 100
Z = INSTR(1, STR$(calc#), ".") ' find the decimal point
IF Z = 0 THEN ' no decimal point means all whole figures
calc3# = calc#
ELSE
calc1# = VAL(MID$(STR$(calc# + 0.005), INSTR(STR$(calc# + 0.005), "."), 3)) ' extract and round up the decimals
calc2# = VAL(MID$(STR$(calc#), 1, (Z - 1))) ' extract the whole number
calc3# = calc2# + calc1# ' combine the whole number and decimal
IF Z = 0 THEN calc3# = calc#
END IF
END IF
GFCTP$ = STR$(calc3#) '
RESULTS
"GFCT$","000025","GFOT$","000003","GFCT#",25,"GFOT#",3,"calc#",89.2857142857143,"calc1#",.29,"calc2#",89,"calc3#",89.29000000000001,"GFCTP$"," 89.29000000000001"
Why do I get the 89.29000000000001 ?? .. on windows 7 it comes out as 89.29 .. along with 1000s of similar calculations. Just every now and then I get a huge number
Thanks,
Mike