sum up currencyedits

I have about 10 currencyedit's and would like to sum them up in one currencyedit.
How and what would be the best way ?
VrtnarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eddie ShipmanAll-around developerCommented:
name them consecutively like this edtCurr1, edtCurr2, ..edtCurr10, and
use the FindComponent method like this:

var
  i: Integer;
  c: Extended;
  e: TEdit;
begin
  c := 0.0;
  for i := 1 to 3 do
  begin
    e := TEdit(FindComponent('edtCurr'+ IntToStr(i)));
    c := StrToFloat(e.Text) + c;
  end;
  Edit4.Text := FloatToStr(c);
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerCommented:
oops, change the for to 1 to 10.
and change Edit4.Text to edtCurr11.Text

only had 3 on my form for testing.
0
VrtnarAuthor Commented:
any alternatives to renaming ??
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

VrtnarAuthor Commented:
I raised an exception class... RConvert error - ''' is not a valid floating value
when I tried your suggestion...
Does not work...
0
VrtnarAuthor Commented:
It seems that when the value of the currencyedit is 0,00 €
then the exception is raised...
0
VrtnarAuthor Commented:
it seems I must set  zeroempty = False of the curredits to get this thing to work...
0
VrtnarAuthor Commented:
eddie...I have made this work by changing the zeroempty thinggie...
Is there a way to update the currency13 (the one that sums up)
when onchange of the currencyedits occur without having to write
every single onchange event of each curredit??
0
Eddie ShipmanAll-around developerCommented:
You can set them all to the same OnChange event to do the computation.
0
Eddie ShipmanAll-around developerCommented:
Or if you have other code in the Onchange events, write a separate method to do the change and
call it from each of them.
0
VrtnarAuthor Commented:
"You can set them all to the same OnChange event to do the computation" -
can you give me an example,please...??
0
Eddie ShipmanAll-around developerCommented:
if you have one OnChange event, set the OnChange event for ALL your edits to the same
event handler in th eObject Inspector, use the dropdown and select the correct handler.
0
VrtnarAuthor Commented:
well..I learn something new in Delphi every day...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.