Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21260

Loop a code on picturebox

$
0
0
Hello VBForum

I'm trying do creat a lille puzzel game, and i want to move all picture around, but i can't be true that it is not possible to do the code in a loop

for now i have

Code:

Private Sub PictureBox20_MouseMove(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox20.MouseMove
        Static mousePosX As Single, mousePosY As Single
        If e.Button = 0 Then
            mousePosX = e.X
            mousePosY = e.Y
        Else
            PictureBox20.Left = PictureBox20.Left + (e.X - mousePosX)
            PictureBox20.Top = PictureBox20.Top + (e.Y - mousePosY)
        End If
    End Sub
    Private Sub PictureBox21_MouseMove(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox21.MouseMove
        Static mousePosX As Single, mousePosY As Single
        If e.Button = 0 Then
            mousePosX = e.X
            mousePosY = e.Y
        Else
            PictureBox21.Left = PictureBox21.Left + (e.X - mousePosX)
            PictureBox21.Top = PictureBox21.Top + (e.Y - mousePosY)
        End If
    End Sub
    Private Sub PictureBox22_MouseMove(ByVal sender As Object, _
                                ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox22.MouseMove
        Static mousePosX As Single, mousePosY As Single
        If e.Button = 0 Then
            mousePosX = e.X
            mousePosY = e.Y
        Else
            PictureBox22.Left = PictureBox22.Left + (e.X - mousePosX)
            PictureBox22.Top = PictureBox22.Top + (e.Y - mousePosY)
        End If
    End Sub

And so on .. and so on ..

Anyone there can help me put this into a loop? ;)

Viewing all articles
Browse latest Browse all 21260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>