Solved

sum up currencyedits

Posted on 2007-03-27
12
158 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
Comment Utility
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
Comment Utility
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
Comment Utility
any alternatives to renaming ??
0
 

Author Comment

by:Vrtnar
Comment Utility
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
Comment Utility
It seems that when the value of the currencyedit is 0,00 €
then the exception is raised...
0
 

Author Comment

by:Vrtnar
Comment Utility
it seems I must set  zeroempty = False of the curredits to get this thing to work...
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Vrtnar
Comment Utility
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
Comment Utility
You can set them all to the same OnChange event to do the computation.
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
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
Comment Utility
"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
Comment Utility
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
Comment Utility
well..I learn something new in Delphi every day...
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

10 Experts available now in Live!

Get 1:1 Help Now