How can I make i loop where I set a variable on the controls to the same value?

textBox1, textBox2, textBox3

for(i=0;i<2;i++){
textBox?????.Text="That's how you do it!";
}

you want an array of textboxes.

That should not be nessesary I think!

I think this is close, but not quite it:

for(i=1; i<4; i++){
foreach(TextBox t in this.Controls)
if(t.Name == "textBox"+i)
t.Text= "Something"
}

Yeah, um, I would say that shouldn't be necessary; you want an array of textboxes instead.

hey man thanks
But i don't really have that options...i mean i dont't want to group them in an array, so im looking for an alternative approach instead

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.