for next loop not working

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi,

could someone explain why the following simple bit of code does not work?

Private Sub Image1_Click()
For x = 10 To 1
Image1.Width = x
Next x
End Sub

Note:
- the image DOES load properly on form initialisation (just doesn't change
in width when clicked)
- the following DOES work: -

Private Sub Image1_Click()
x = 32 ' arbitrary figure
Image1.Width = x
End Sub

but obviously is a one off action

grateful fro any answers,

tim
 
could someone explain why the following simple bit of code does not work?

Private Sub Image1_Click()
For x = 10 To 1
Image1.Width = x
Next x
End Sub


Try (2nd line)

For x = 10 to 1 Step -1


--ron
 
Ron Rosenfeld said:
Try (2nd line)

For x = 10 to 1 Step -1

thanks Ron, it works, but i thought if i did it as a loop, it would have a
smooth transition, it just seems to go from all to nothing in one go (maybe
i need a line to update the form?)

tim
 
thanks Ron, it works, but i thought if i did it as a loop, it would have a
smooth transition, it just seems to go from all to nothing in one go (maybe
i need a line to update the form?)

I haven't worked with this sort of stuff, but maybe you just need to slow down
your loop with a delay. Either a nested loop or use the Timer function.


--ron
 
Where is the image control? On a userform or a worksheet

How slow do you want the transition?
 

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