Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looping through an array

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have the following code. I am tring to add each element of dependents to it's own textbox names child1 through 10. Right now it is telling me that child is not declared

Dim i as integer
dim j as integer
j = Ubound(dependents)

j = j + 1

i = 1

Do while i < j
child & i.text = dependents
i = i + 1
loop

I have tried child & i, and child + 1.
 
what you need to do is to put child 1 - 10 into an array of size 10.

then loop through that array using:

childArray(i).text = ....

to assign the values:


dim childArray(10) as textbox
childArray(0) = child1
childArray(1) = child2
.....

for i = 0 to 9
childArray(0).text = dependent.text
next

something to that affect... you can't refer to variable names as if they were strings.
penny1.gif
penny1.gif
 
link9 I am a little confused. you put the webcontrols into an array? or the name into an array?
 
right now I have an array called dependents which stores the child in each element.
 
my biggest problem is I don't know how many elements are in the array. I have specified a maximum of 10 textboxes on the page, but that doesn't mean all of them will have a value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top