WHO REMEMBER this old window

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Code: Select all

Option Explicit

Dim Times As Long

Private Sub START_ANIM()
    Me.ScaleMode = vbPixels

    With PICTLISTVIEW
        .Visible = True
        .ScaleMode = vbPixels
    End With

    Times = 1

    With Timer3
        .Interval = 1
        .Enabled = True
    End With

    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed
End Sub

Private Sub Command1_Click()
    Call START_ANIM
End Sub

Private Sub Timer3_Timer()
    With Me.PICTLISTVIEW
        If .Left + xSpeed > x2 Then
            .Move x1, y1
            Times = Times + 1
            If Times > 3 Then
                Timer3.Enabled = False
                .Visible = False
            End If
        Else
            .Move .Left + xSpeed, .Top + ySpeed
        End If
    End With
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
01 Mar 2022, 18:13

Code: Select all

Option Explicit

Dim Times As Long

Private Sub START_ANIM()
    Me.ScaleMode = vbPixels

    With PICTLISTVIEW
        .Visible = True
        .ScaleMode = vbPixels
    End With

    Times = 1

    With Timer3
        .Interval = 1
        .Enabled = True
    End With

    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed
End Sub

Private Sub Command1_Click()
    Call START_ANIM
End Sub

Private Sub Timer3_Timer()
    With Me.PICTLISTVIEW
        If .Left + xSpeed > x2 Then
            .Move x1, y1
            Times = Times + 1
            If Times > 3 Then
                Timer3.Enabled = False
                .Visible = False
            End If
        Else
            .Move .Left + xSpeed, .Top + ySpeed
        End If
    End With
End Sub
super!

sorry but important...

how to do the reverse from end to start

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Do you want to go back and forth three times?
Or do you want to go back three times?
Or ...
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

In effet with the First cycle i simulate to send in cart a produt, from market to cart.
But of the user want ti delete i need to simulate, from cart to market...
I Hope you undestand.

Note:
The cycle rapresent the Number of product.
From market icon to cart icon.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

If you want to move back, simply switch x1 and y1 with x2 and y2.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
01 Mar 2022, 22:55
If you want to move back, simply switch x1 and y1 with x2 and y2.
ok, but where?

here:

' Start Position
Public Const x1 As Single = 680, y1 As Single = 100
' End position
Public Const x2 As Single = 1015, y2 As Single = 100

or here:
ySpeed = (y2 - y1) / (x2 - x1) * xSpeed

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

At the start, instead of

Code: Select all

    .Left = x1
    .Top = y1
or

Code: Select all

     .Move x1, y1
use

Code: Select all

    .Left = x2
    .Top = y2
or

Code: Select all

    .Move x2, y2
And also use

Code: Select all

            .Move .Left - xSpeed, .Top - ySpeed
instead of

Code: Select all

            .Move .Left + xSpeed, .Top + ySpeed
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
02 Mar 2022, 11:14
At the start, instead of

Code: Select all

    .Left = x1
    .Top = y1
or

Code: Select all

     .Move x1, y1
use

Code: Select all

    .Left = x2
    .Top = y2
or

Code: Select all

    .Move x2, y2
And also use

Code: Select all

            .Move .Left - xSpeed, .Top - ySpeed
instead of

Code: Select all

            .Move .Left + xSpeed, .Top + ySpeed
Confused...

the picturebox go out to the left....


in module
'ANIMAZIONE
Public Const xSpeed As Single = 5
Public ySpeed As Single
' Start Position
Public Const x1 As Single = 795, y1 As Single = 145
' End position
Public Const x2 As Single = 968, y2 As Single = 145
'ANIMAZIONE
in module

Code: Select all

Option Explicit
Dim Times As Long
Private Sub START_ANIM()

    Me.ScaleMode = vbPixels

    With PICTLISTVIEW
        .Visible = True
        .ScaleMode = vbPixels
        .Left = x2
    End With

    Times = 1

    With Timer3
        .Interval = 1
        .Enabled = True
    End With

    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed

End Sub
Private Sub Command1_Click()

    Call START_ANIM

End Sub
Private Sub Timer3_Timer()

    With Me.PICTLISTVIEW
        If .Left + xSpeed > x2 Then
            .Left = x1
            Times = Times2 + 1
            If Times > 3 Then
                Timer3.Enabled = False
                .Visible = False
            End If
        Else
            '.Move .Left + xSpeed, .Top + ySpeed
            .Move .Left - xSpeed, .Top - ySpeed
        End If
    End With

End Sub
Last edited by sal21 on 03 Mar 2022, 15:02, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Also change

Code: Select all

        If .Left + xSpeed > x2 Then
            .Move x1, y1
to

Code: Select all

        If .Left - xSpeed < x1 Then
            .Move x2, y2
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
03 Mar 2022, 15:01
Also change

Code: Select all

        If .Left + xSpeed > x2 Then
            .Move x1, y1
to

Code: Select all

        If .Left - xSpeed < x1 Then
            .Move x2, y2
:clapping: