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.
Who is Participating?
intheConnect With a Mentor Commented:
you can use something like this to change the value:

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

then TDBEdit onchange event do
edit1.text := strtoint(TDBEdit.text * variable you saved);
Eduardo1Author Commented:
We're almost there...!!!

What I have right now is this:

procedure TfrmDepartamentos.DBEdit5Change(Sender: TObject);
   if DBCheckBox1.Checked then

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.
ok i will see what i can do in a test later and let you know.

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

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..
Eduardo1Author Commented:

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

I placed the code:

   if DBCheckBox1.Checked then

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...!
hehe no problem ,
glad to be of help ;-)
see you again
Regards Barry
All Courses

From novice to tech pro — start learning today.