Try this code:
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseMove
If (e.Button = Windows.Forms.MouseButtons.Left) Then
Dim x As Integer = (Me.pbpos.X + (Control.MousePosition.X - Me.offset.X))
Dim y As Integer = (Me.pbpos.Y + (Control.MousePosition.Y - Me.offset.Y))
x = Math.Min(Math.Max(x, -(Me.PictureBox1.Width - Me.Panel1.Right)), 0)
y = Math.Min(Math.Max(y, -(Me.PictureBox1.Height - Me.Panel1.Bottom)), 0)
Me.PictureBox1.Location = New Point(x, y)
End If
End Sub