943,867 Members | Top Members by Rank

Ad:
Apr 2nd, 2008
0

Delphi edit box help

Expand Post »
I'll make it blunt of what I can't seem to get my head round.

I have two edit boxs, values in both, and I want the value in editbox1 to be added to the value in editbox2. And then the value appear in editbox2.

If you can think of a way to do this, then please say

thank you
~bbradley
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bbradley is offline Offline
14 posts
since Apr 2008
Apr 3rd, 2008
1

Re: Delphi edit box help

editbox2.value := editbox1.value + editbox2.value;

invalidate;

place these two lines in the code where thecalculation is required. Invalidate will cause the editboxes to be re-diplayed with the current values. Note that the "value" tion is a place holder for whatever variable you are using to hold the value.

If you using a standard editbox and the value is stored in the caption property, the value name should change to caption. If you are using the caption rememeber that it is a string and you will have to convert the caption string to an integer or float value before the addition can be applied.

The first line would then read :

editbox2.caption := floatToStr (strToFloat (editbox1.caption)+ strToFloat(editbox2.caption));

if the value is an integer use strToInt & IntTostr functions. Also, remember to include sSysUtil in the Uses clause for the unit if it isn't already there.
Reputation Points: 11
Solved Threads: 11
Junior Poster in Training
jsosnowski is offline Offline
68 posts
since Nov 2007
Apr 4th, 2008
1

Re: Delphi edit box help

Click to Expand / Collapse  Quote originally posted by bbradley ...
I'll make it blunt of what I can't seem to get my head round.

I have two edit boxs, values in both, and I want the value in editbox1 to be added to the value in editbox2. And then the value appear in editbox2.

If you can think of a way to do this, then please say

thank you
~bbradley
If you are adding 2 numeric values then the code would look like this:

editbox2.text:= floattostr(strtofloat(editbox1.text)+strtofloat(editbox2.text));


If you are concatenating to values then it would look like this:

editbox2.text:= editbox1.text+editbox2.text;
Reputation Points: 12
Solved Threads: 1
Newbie Poster
RandyRich is offline Offline
6 posts
since Apr 2008
Apr 4th, 2008
0

Re: Delphi edit box help

Thank you for your help!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bbradley is offline Offline
14 posts
since Apr 2008
Apr 4th, 2008
0

Re: Delphi edit box help

Thanks for the catch on my error. It is text , not caption!
Reputation Points: 11
Solved Threads: 11
Junior Poster in Training
jsosnowski is offline Offline
68 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: TMemo - feedback if mouse clicked in area outside existing lines
Next Thread in Pascal and Delphi Forum Timeline: How can I update a new removable drive in the DriveComboBox (urgent!)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC