Calculated TEdit in a form

Hi everyone...

In a form I have, a TDBEdit object displays a numeric value from my table. I placed a TEdit object near it, on the same form, and I'd like to have it reflect that amount multiplied times 1.15.

How can I do it?
Can it display itself conditionally based on the value of a TDBCheckBox on the same form? (It's also the same table.)
How can I have an edit box to make the 1.15 modifiable by the user?

Thanks, best regards.
Eduardo
Eduardo1Asked:
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.

intheCommented:
you can use something like this to change the value:

procedure TForm1.Button2Click(Sender: TObject);
var
   Nombre:string;
   PulsoOk:boolean;
 begin
   PulsoOk:= InputQuery('hello',
      'please enter number...', Nombre);
   if PulsoOk
     then
{save this number in variable or registry or ini file etc..}
  else ShowMessage('no number');
 end;

then TDBEdit onchange event do
edit1.text := strtoint(TDBEdit.text * variable you saved);
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
Eduardo1Author Commented:
We're almost there...!!!

What I have right now is this:

procedure TfrmDepartamentos.DBEdit5Change(Sender: TObject);
begin
   if DBCheckBox1.Checked then
   editConIva.Text:=InttoStr(StrtoInt(DBEdit5.text)*2)
   else
   editConIva.Text:='';
end;

1. I need to insert a real type where the number 2 is, but there's no such thing as RealtoStr or StrtoReal.
2. When I get to a record where DBCheckBox1.Checked = True, the value doesn't show on the same record, but on the next one that appears on the form.

Thanks for your help.
0
intheCommented:
ok i will see what i can do in a test later and let you know.

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

intheCommented:
ahh i forget to convert real to string and string to real you can use FloattoStr() and StrToFloat() functions instead.

and for the value doesn't show on the same record maybe it will work better on the DBEdits OnEnter or OnExit events..
0
Eduardo1Author Commented:
Victory!!!

I used the FloattoStr() and StrtoFloat() functions, and they worked great.

I placed the code:

   if DBCheckBox1.Checked then
   editConIva.Text:=FloattoStr(StrtoFloat(DBEdit5.text)*1.15)
   else
   editConIva.Text:='';

in the DBNavigator OnClick event handler. Then I tested checking the checkbox on the first record, and when it didn't work I copied the code and added it to the FormCreate event. That did it!

Thanks inthe... you pressed the right buttons in my brain so we could both solve this.

I feel good...!
0
intheCommented:
hehe no problem ,
glad to be of help ;-)
see you again
Regards Barry
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.