I have a Picturebox on my Form that I'd like to be able to drag left and right but to only go so far (limitations). I have set the left limitation to 2400 and the right to 6000. It drags fine, but once it reaches the limitations, it doesn't stop. Here is my code:
It works, but when it gets to the left and right limitations, it does this:Code:Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Static lx As Single, ly As Single If Button = vbLeftButton Then If (Picture1.Left > 2399) And (Picture1.Left < 6001) Then Picture1.Left = Picture1.Left + (X - lx) Else If Picture1.Left < 2400 Then Picture1.Left = 2400 If Picture1.Left > 6000 Then Picture1.Left = 6000 End If Else lx = X: ly = Y End If End Sub
It also randomly continues past the limitations. Anyway to correct this?




Reply With Quote
