Solved

sum up currencyedits

Posted on 2007-03-27
12
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 92
Convert a string into a TDateTime 5 72
Microsoft Access 97 and Delphi XE2 9 72
Delphi android app hide keyboard 3 43
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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