Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Trying to neatly add a range of edit fields
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
0 · ·