Topic: Invalid floating point operation on Calc.
I was trying to do simple win/loss percent calc.
With one calc it worked fine. When I added another win/loss calc on same page it returns "Invalid floating point operation"
The script below works with one calc on the same page:
procedure CalculateTotal;
begin
Form1.edWinPercent.Value := Form1.edWinCount.value / (Form1.edWinCount.value + Form1.edLossCount.value) * 100;
Form1.edLossPercent.Value := Form1.edLossCount.value / (Form1.edWinCount.value + Form1.edLossCount.value) * 100;
end;
procedure Form1_edWinCount_OnChange (Sender: string);
begin
CalculateTotal;
end;
procedure Form1_edLossCount_OnChange (Sender: string);
begin
CalculateTotal;
end;
The script below doesn't work when added second calc. I've tried adding variables but couldn't get it working?
procedure CalculateTotal;
var
WinPercent, LossPercent: Real;
WinPercent2, LossPercent2: Real;
begin
WinPercent:= Form1.edWinPercent.value;
LossPercent:= Form1.edLossPercent.Value;
WinPercent2:= Form1.edWinPercent2.value;
LossPercent2:= Form1.edLossPercent2.Value;
begin
Form1.edWinPercent.Value := Form1.edWinCount.value / (Form1.edWinCount.value + Form1.edLossCount.value) * 100;
Form1.edLossPercent.Value := Form1.edLossCount.value / (Form1.edWinCount.value + Form1.edLossCount.value) * 100;
Form1.edWinPercent2.Value := Form1.edWinCount2.value / (Form1.edWinCount2.value + Form1.edLossCount2.value) * 100;
Form1.edLossPercent2.Value := Form1.edLossCount2.value / (Form1.edWinCount2.value + Form1.edLossCount2.value) * 100;
end;
end;
procedure Form1_edWinCount_OnChange (Sender: string);
begin
CalculateTotal;
end;
procedure Form1_edLossCount_OnChange (Sender: string);
begin
CalculateTotal;
end;
procedure Form1_edWinCount2_OnChange (Sender: string);
begin
CalculateTotal;
end;
procedure Form1_edLossCount2_OnChange (Sender: string);
begin
CalculateTotal;
end;
It may sound silly as to why I need more than one calc of same; on a same page but I needed. Each calc applies to different items on a same page.
Please see the attached sample project if needed:
God... please help me become the person my dog thinks I am.