Solved

sum up currencyedits

Posted on 2007-03-27
12
159 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

948 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now