Question make a own scrollbar with a limit


New member
Feb 13, 2014
Programming Experience
Hi guys,

I would like to make a scrollbar with limit stops at the top and bottom, but it does work but then stops me picturebox complete and does nothing and is no longer down! Who can help me please?


Public Class Form1

    Dim startx As Integer
    Dim starty As Integer
    Dim endy As Integer
    Dim endx As Integer
    Dim finalx As Integer
    Dim finaly As Integer
    Dim mdown As Boolean
    Dim valx As Boolean
    Dim valy As Boolean

    Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
        starty = MousePosition.Y
        mdown = True
        valx = False
        valy = False
    End Sub

    Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
        If mdown = True Then
            endy = (MousePosition.Y - Me.Top)

            If valy = False Then
                starty = endy -
                valy = True
            End If
            If valx = False Then
                startx = endx - sender.left
                valx = True
            End If
   = endy - starty
        End If
        If PictureBox1.Location.Y = -2 = True Then
            valy = False
            If PictureBox1.Location.Y = 136 = True Then
                valy = False
            End If
        End If
    End Sub

    Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
        mdown = False
        valx = False
        valy = False
    End Sub


Last edited by a moderator:
Top Bottom