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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid name

Status
Not open for further replies.

andreas57

Technical User
Sep 29, 2000
110
CH
when i use a for-loop to go through 10 imageboxes like this:

for a=0 to 9
image(a).caption=a+5
next a

i allways get the error: invalid name. what can i do?

andreas owen
aowen@swissonline.ch
 
An image does not have a caption property.

David Paulson


 
sorry that was an example

for a=0 to 9
image(a).left=a+5
next a


andreas owen
aowen@swissonline.ch
 
it allways marks "image" and says invalid name

andreas owen
aowen@swissonline.ch
 
You can only access a control array in that way, not individual controls. Did you copy and paste one control or create a new control each time. They will be named differently upon creation.

individual controls control array

image1 image1(0)
image2 image1(1)
image3 image1(2)

David Paulson


 
control array

image(1)
image(2)
...

i've seen it work by someone else but i just can't succeed for some reason

andreas owen
aowen@swissonline.ch
 
could it be that this doesn't work because i still use vb 5.0?

andreas owen
aowen@swissonline.ch
 
you can't do that, even in vb6, you must create an array, and then use the index property of the array:

This don't work:
for a=0 to 9
image(a).left=a+5
next a

This works fine:
for a=0 to 9
image1(a).left=a+5
next a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top