how to join up a string and a integer to be a object name ?

T

THY

Hi,

Assuming that I have 5 textboxes, they are textbox1, textbox2, textbox3,
textbox4, textbox5.
and now I am on a for loop as below. but how can I make it join the word
"textbox" and my i value together and be a textbox object ?

it should be something like that, but I dont know the real coding.

for i = 1 to 5
("textbox" & i).text = "hello"
next


anyone know it ?

your help is real appreaciated. Thanks.
 
J

Jos

THY said:
Hi,

Assuming that I have 5 textboxes, they are textbox1, textbox2,
textbox3, textbox4, textbox5.
and now I am on a for loop as below. but how can I make it join the
word "textbox" and my i value together and be a textbox object ?

it should be something like that, but I dont know the real coding.

for i = 1 to 5
("textbox" & i).text = "hello"
next

CType(FindControl("textbox" & i),TextBox).Text="Hello"
 
J

John Saunders

THY said:
Hi,

Assuming that I have 5 textboxes, they are textbox1, textbox2, textbox3,
textbox4, textbox5.
and now I am on a for loop as below. but how can I make it join the word
"textbox" and my i value together and be a textbox object ?

it should be something like that, but I dont know the real coding.

for i = 1 to 5
("textbox" & i).text = "hello"
next

Private textBoxArray As TextBox() = New TextBox() {textbox1, textbox2, ...
textbox5}

For i = 1 To 5
textBoxArray(i).Text = "hello"
Next
 
T

THY

This is a good way too, thanks John !

John Saunders said:
Private textBoxArray As TextBox() = New TextBox() {textbox1, textbox2, ...
textbox5}

For i = 1 To 5
textBoxArray(i).Text = "hello"
Next
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top