Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read and change the value of a TEdit control?

Tags:

delphi

I have a Form TForm1 having 5 TEdit and 2 TBitBtn.

I also need the Program so that after inputting Numeric Data in Edit1 and Edit2 on BitBtn1Click, Edit1 and Edit2 value will summed and will be displayed in Edit3.

like image 835
Koushik Halder Avatar asked Dec 16 '11 17:12

Koushik Halder


1 Answers

You want to do something like this:

var
  val1, val2, sum: Integer;
...
val1 := StrToInt(Edit1.Text);
val2 := StrToInt(Edit2.Text);
sum := val1 + val2;
Edit3.Text := IntToStr(sum);

If you want floating point arithmetic do it like this

var
  val1, val2, sum: Double;
...
val1 := StrToFloat(Edit1.Text);
val2 := StrToFloat(Edit2.Text);
sum := val1 + val2;
Edit3.Text := FloatToStr(sum);
like image 187
David Heffernan Avatar answered Sep 18 '22 02:09

David Heffernan