Link to home
Start Free TrialLog in
Avatar of visionetv
visionetvFlag for United States of America

asked on

Use Delphi to add an integer to a Tedit name

Hi Experts;

Is it possible to add an integer to the name of a TEdit component from a loop? I'm trying to add an integer to the name of a number of edit boxes that contain various .text strings so I can iterate through the group and compare their text to a another string in another edit box... something like this:

For n := 1 to 40 do
begin
If Edit+IntToStr(n)+.text = Editbox1.text then
begin
(ShowMessage Edit+IntToStr(n) + 'is a match')
end;

The above of course does not work. There must be a way to do what should be a simple string comparison operation but apparently my approach is on the wrong track; any help would be appreciated.

Thank you,
Visionetv
Avatar of akb
akb
Flag of Australia image

Instead of adding an integer to the component name it would be easier to put your components into an array.

Instead of:
  EditBox1: TEdit;
  EditBox2: TEdit;
  EditBox3: TEdit;

Use:
  EditBox: array[1..3] of TEdit;
as a Public declaration.

Then use EditBox[n] in your program.

It's a while since I've used Delphi but hopefully this will point you in the right direction.
ASKER CERTIFIED SOLUTION
Avatar of MerijnB
MerijnB
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of visionetv

ASKER

MerijnB;

Thank you - application checks for duplicate entries in a Purchase Order form where all the fields are edit boxes. The form can have up to forty entries, so speed is not a problem.

Thanks again,
Visionetv