Image moving strangely

i put 2 images into my form on the bottom side).
image1 and image2, image 1 is in the back of image2,
then i wrote this code :
Private Sub Image2_click()
image1.visible = true
For A = 5000 to 2000 step -0.01
Image1.move image1.left,A
Next A
image1.visible = false
end sub
When i klik on image2, it shows image1 is moving, but...
the moving looked strange, can anyone help me?

Comments

  • : i put 2 images into my form on the bottom side).
    : image1 and image2, image 1 is in the back of image2,
    : then i wrote this code :
    : Private Sub Image2_click()
    : image1.visible = true
    : For A = 5000 to 2000 step -0.01
    : Image1.move image1.left,A
    : Next A
    : image1.visible = false
    : end sub
    : When i klik on image2, it shows image1 is moving, but...
    : the moving looked strange, can anyone help me?
    :
    Hi, using DoEvents after every step will be useful. But this will look strange (exactly on slower machines). Move is not the fastest way how to move image and 5000 to 2000 step 0,01 is 300 000 loops. Ooohhh...

    I've created one timer Timer1, set Enabled=False and Interval=50 (ms).
    You can improve the speed by setting interval and *
    [code]Private Sub Image2_click()
    Image1.Top = 5000
    Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Timer()
    If Image1.Top <= 2000 Then
    Timer1.Enabled = False
    Else
    Image1.Top = Image1.Top - 100 [green]' * and this[/green]
    End If
    DoEvents
    End Sub[/code]
    Another way should be using API Sleep function. It will be similar

    [code] For i = 5000 to 2000 step - 100
    Image1.Top = i
    Sleep(50)
    DoEvents
    Next i
    [/code]

    PavlinII
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion