Shauli: You are moving the control with the keyboard. If I understand the question correctly, you should use the mouse.
Private StoredY As Single
Private Sub MyControl_MouseDown(Button
If Button = 1 Then
StoredY = Y
End If
End Sub
Private Sub MyControl_MouseMove(Button
If Button And 1 Then
MyControl.Top = MyControl.Top + Y - StoredY
End If
End Sub
Note: I presumed you only want to move the control on the left mouse button. If you would like to use any button, delete the lines "If" and "End If" in the first function and modify "Button And 1" to "Button" in the second.
HTH
Main Topics
Browse All Topics





by: ShauliPosted on 2005-02-10 at 16:47:55ID: 13281978
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub MoveControl(ByRef sbControl As Control, ByVal sbAmount As Integer, sbUpDown As Byte)
sbControl.Top = IIf(sbUpDown = 1, sbControl.Top + sbAmount, sbControl.Top - sbAmount)
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyDown
MoveControl Screen.ActiveControl, 15, 1
Case vbKeyUp
MoveControl Screen.ActiveControl, 15, 0
End Select
End Sub
S