VScroll does not work with Line added - Run-time error '438'.

I have found a code sample out there that lets me add in a vscroll bar so that I can scroll my form.  I'm able to scroll fine, until I added some lines.  The error that I'm getting is as followed:

Run-time error '438': Object doesn't support this property or method.

Here's the code and I use and the line where I"m having issues with.


Option Explicit

Dim oldPos As Integer

Private Sub Form_Load()
Dim iFullFormHeigth As Integer
Dim iDisplayHeight  As Integer

iFullFormHeigth = 12900
iDisplayHeight = 3000

Me.Height = iDisplayHeight

With VScroll1
    .Height = Me.ScaleHeight
    .Min = 0
    .Max = iFullFormHeigth - iDisplayHeight
    .SmallChange = Screen.TwipsPerPixelY * 10
    .LargeChange = .SmallChange
End With

End Sub


Private Sub pScrollForm()
Dim ctl As Control
For Each ctl In Me.Controls
    If Not (TypeOf ctl Is VScrollBar) And _
        Not (TypeOf ctl Is CommandButton) Then
        ctl.Top = ctl.Top + oldPos - VScroll1.Value   -----------------------------------> Here's where it errors out.  Looks like .Top can't be use with line or something.
    End If
Next

oldPos = VScroll1.Value
End Sub

Private Sub VScroll1_Change()
    Call pScrollForm
End Sub


Private Sub VScroll1_Scroll()
    Call pScrollForm
End Sub
holemaniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Indeed, the line control does not have Top, left etc, but has x1, x2, y1 and y2 to determine from where to where the line should go.


Private Sub pScrollForm()
Dim ctl As Control
For Each ctl In Me.Controls
    If Not (TypeOf ctl Is VScrollBar) And _
       Not (TypeOf ctl Is CommandButton) Then
           if TypeOf ct is Line then
              ctl.y1 = ctl.y1 + oldPos - VScroll1.Value  
              ctl.y2 = ctl.y2 + oldPos - VScroll1.Value  
           else
              ctl.Top = ctl.Top + oldPos - VScroll1.Value  
           end if
    End If
Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
holemaniaAuthor Commented:
Wow that was quick.  Thanks for the help!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.