Allow Controls To Move

'Add 1 PictureBox to your form.
'This example will show you how to allow the user to move PictureBox.
'You can do the same thing with other controls.
'Insert the following code to your form:

Public globalX As Integer
Public globalY As Integer

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'Replace All 'Picture1' with the name of the control you want to move.
Picture1.Move X - globalX, Y - globalY
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Drag vbBeginDrag
globalX = X
globalY = Y
End Sub

Go Back