: I've got about 27 edit boxes on a form, which should result in a total.
: Can someone help me create a neat little bit of code to do this (As opposed to something horrible like "i := StrToInt(Edit1.Text) + StrToInt(Edit2.Text) +".
: I've tried this little code:
: procedure TForm1.Button1Click(Sender: TObject);
: i,ii,si : integer;
: s : String;
: ii := 0;
: for i := 1 to 27 do
: s := 'Edit'+IntToStr(i)+'.Text';
: si := StrToInt(s);
: ii := ii + si;
: But whenever I run that code, it gives me an error that says
: 'Edit1.Text' is not a valid integer value.
: Cheers in advance
In your code the value of s is not code, but a normal string.
You should use the FindComponent() method to get the component reference. Then type-cast the component to an TEdit, and then you can access the Text property.