• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

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
0
holemania
Asked:
holemania
1 Solution
 
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
 
holemaniaAuthor Commented:
Wow that was quick.  Thanks for the help!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now