Topic: for loop for all

hello all

if i have 10 TextBox

TextBox1  ,  TextBox2  , TextBox3 ..... ......  TextBox10

how can i use for loop for all TextBox 

example

var i:Integer;
begin

    for i:=1 to 10 do
            begin

            form1[TextBox+i].value :=int(random(100));

            end;

thanks for help

Re: for loop for all

Good Day.
Here's a sample.

Post's attachments

Attachment icon LoopComponent.zip 493.24 kb, 271 downloads since 2020-12-30 

brian

Re: for loop for all

hello brian.zaballa

thank you very much

you are good man

Re: for loop for all

hello  brian.zaballa

How can I exclude TextBox1

i used this code but not working

for i:=2 to (cCount-1) do begin
        IF Form1.Components[i] is TdbEdit
            Then TdbEdit(Form1.Components[i]).Value := int(random(100));
    end;

thanks for help

Re: for loop for all

Try using for i:=1 to (cCount-1) do begin .  Loops normally start at zero, though you do not say what result you are getting with the current code so pointing you in the right direction is a guess at best.

On a clear disk you can seek forever

Re: for loop for all

hello Member

thank you and happy new year