Solved

sum up currencyedits

Posted on 2007-03-27
12
160 Views
Last Modified: 2010-04-05
I have about 10 currencyedit's and would like to sum them up in one currencyedit.
How and what would be the best way ?
0
Comment
Question by:Vrtnar
  • 7
  • 5
12 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 50 total points
ID: 18800221
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
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18800233
oops, change the for to 1 to 10.
and change Edit4.Text to edtCurr11.Text

only had 3 on my form for testing.
0
 

Author Comment

by:Vrtnar
ID: 18800565
any alternatives to renaming ??
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Vrtnar
ID: 18800681
I raised an exception class... RConvert error - ''' is not a valid floating value
when I tried your suggestion...
Does not work...
0
 

Author Comment

by:Vrtnar
ID: 18800797
It seems that when the value of the currencyedit is 0,00 €
then the exception is raised...
0
 

Author Comment

by:Vrtnar
ID: 18800821
it seems I must set  zeroempty = False of the curredits to get this thing to work...
0
 

Author Comment

by:Vrtnar
ID: 18800904
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
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18801435
You can set them all to the same OnChange event to do the computation.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18801444
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
 

Author Comment

by:Vrtnar
ID: 18801564
"You can set them all to the same OnChange event to do the computation" -
can you give me an example,please...??
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18802479
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
 

Author Comment

by:Vrtnar
ID: 18803900
well..I learn something new in Delphi every day...
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

772 members asked questions and received personalized solutions in the past 7 days.

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

Join & Ask a Question