Move images in VB6

0
Option Compare Database

Private Sub Command0_Click()
    Do Until Me.Width < 4000
        Let Image1.Left = Image1.Left - 5
    DoEvents
    Loop
End Sub

As this allows you to move the image from right to left, how do the image to rotate the entire form, without stopping with a button and without using the timer? Does anyone have an effective idea how to do this?

    
asked by anonymous 05.06.2014 / 14:00

2 answers

1

First I would drop your variable Indo . In this case, I would use a Enum :

Enum Movimento
    Cima
    Baixo
    Esquerda
    Direita
End Enum

And would declare a variable called mov :

Dim mov as Movimento

In this case, the Sub would have to have, instead of a If , a Select Case :

Select Case mov
    Case Movimento.Cima
        Picture1.Left = Picture1.Top - 10

        'Se bateu em cima, vai pra esquerda
        If Picture1.Top >= ScaleHeight - Picture1.Height Then
            mov = Movimento.Esquerda
            Picture1.Top = ScaleHeight - Picture1.Height
            Exit Do
        End If
    Case Movimento.Baixo
        Picture1.Left = Picture1.Top + 10

        'Se bateu em cima, vai pra esquerda
        If Picture1.Top >= ScaleHeight - Picture1.Height Then
            mov = Movimento.Direita
            Picture1.Top = ScaleHeight - Picture1.Height
            Exit Do
        End If
    Case Movimento.Esquerda
        Picture1.Left = Picture1.Left + 10

       'Se bateu no lado direito, vai pra baixo
       If Picture1.Left >= ScaleWidth - Picture1.Width Then
            mov = Movimento.Baixo
            Picture1.Left = ScaleWidth - Picture1.Width
            Exit Do
        End If
    Case Else ' Ou seja, Movimento.Direita
        Picture1.Left = Picture1.Left - 10

        'Se bateu no lado esquero, sobe.
        If Picture1.Left <= 0 Then
            mov = Movimento.Cima
            Picture1.Left = 0
            Exit Do
        End If
     End Select

This code will certainly need some adjustment, but it has the general idea.

    
06.06.2014 / 19:03
0

For what I wanted it would look like this:

Option Compare Database
Dim i As Integer
Private Sub Command1_Click()

For i = 1 To 900
Me.Width = 1000
Let Image3.left = Image3.left - 5
DoEvents
Next
For i = 900 To 1200
Me.Width = 1000
Let Image3.top = Image3.top + 5
DoEvents
Next
For i = 1800 To 2700
Me.Width = 1000
Let Image3.left = Image3.left + 5
DoEvents
Next
For i = 2700 To 3000
Me.Width = 1000
Let Image3.top = Image3.top - 5
DoEvents
Next
End Sub
    
12.06.2014 / 10:56