-
Dec 2nd, 2021, 09:01 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] VScrollBar Issue
I have 2 programs with a VScrollBar. They both have the same scrolling code.
The first program was last updated 9/1/20. It has always worked correctly, including today.
The second program is currently being developed. It worked correctly since this code was added. Today it does not work. I get an automation error 438 "Object doesn't support this property or method".
Here is the code. The highlighted code is where the error occurred.
Code:
Private Sub VScroll_Change()
ScrollFrame
End Sub
Private Sub VScroll_Scroll()
ScrollFrame
End Sub
Private Sub ScrollFrame()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Container.Name = "fraScroll" Then
ctl.Top = ctl.Top + (oldPos - VScroll.Value)
End If
Next
oldPos = VScroll.Value
End Sub
Thanks
-
Dec 2nd, 2021, 09:38 AM
#2
Re: VScrollBar Issue
I assume not each control in the collection has an Container property
But if you only want to use control fraScroll then why not directly set it's properties?
Code:
Private Sub ScrollFrame()
fraScroll.Top = fraScroll.Top + (oldPos - VScroll.Value)
oldPos = VScroll.Value
End Sub
-
Dec 2nd, 2021, 09:55 AM
#3
Re: VScrollBar Issue
the reason is that u have a component in your form that doesn't have .Name
but, as Arnoutdv wrote, if you just want to move fraScroll, u don't need For Each,
and if you have an array, u can use a For i = Lbound to UBound
-
Dec 2nd, 2021, 09:57 AM
#4
Thread Starter
Fanatic Member
Re: VScrollBar Issue
Wow. It was that simple. Thanks Arnoutdv.
-
Dec 2nd, 2021, 10:13 AM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] VScrollBar Issue
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|