dynamic controlname txttest+i.text

  • Thread starter Thread starter henk
  • Start date Start date
H

henk

Hi,

I want to change the text of a textbox with a loop like this:
For t = 0 To
txtTest1.text="hello"
txtTest2.text="hello2"
next t

but I want to use the controlname dynamically eg
txtTest+i.text

But wat is the correct syntax for this??

Thanks.
 
Hi Henk,

Maybe you could loop through the forms controls collection and test each for
your control name and if true then set the text:

Dim cnl As Control

Dim t As Integer

For Each cnl In Me.Controls

For t = 0 To 2

If cnl.Name = "Text" & t Then

cnl.Text = "Hello" & t

End If

Next

Next
 
Henk,

If you start new with this take than the Tag property, that you can as well
use with menuitems.

For the rest see one of the samples from Herfried I am sure that there is
one that will fit you.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top