Delphi edit box help

Reply

Join Date: Apr 2008
Posts: 14
Reputation: bbradley is an unknown quantity at this point 
Solved Threads: 0
bbradley's Avatar
bbradley bbradley is offline Offline
Newbie Poster

Delphi edit box help

 
0
  #1
Apr 2nd, 2008
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
I'm currently programming with delphi. Its my first time using Delphi and I'm finding it hard.
Please feel welcome to mail me in anyway to help me along :)
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: Delphi edit box help

 
1
  #2
Apr 3rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: RandyRich is an unknown quantity at this point 
Solved Threads: 1
RandyRich RandyRich is offline Offline
Newbie Poster

Re: Delphi edit box help

 
1
  #3
Apr 4th, 2008
Originally Posted by bbradley View 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
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;
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 14
Reputation: bbradley is an unknown quantity at this point 
Solved Threads: 0
bbradley's Avatar
bbradley bbradley is offline Offline
Newbie Poster

Re: Delphi edit box help

 
0
  #4
Apr 4th, 2008
Thank you for your help!
I'm currently programming with delphi. Its my first time using Delphi and I'm finding it hard.
Please feel welcome to mail me in anyway to help me along :)
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: Delphi edit box help

 
0
  #5
Apr 4th, 2008
Thanks for the catch on my error. It is text , not caption!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC