Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FlatScrollBar-inavlid use of property 1

Status
Not open for further replies.

Ravala

Programmer
Jan 28, 2004
88
US
I can't figure out why I have this error.
I have two picture boxes. One picData as a frame for another picData2 where I load controls in run time.
Private Sub picData_Resize()
Dim sngHeight As Single
' Initializations
sngHeight = 0
scbVert.Visible = (picData2.Height > ScaleHeight)
scbVert.Move ScaleWidth - scbVert.Width - 1000, 0, scbVert.Width, picData.Height
If scbVert.Visible Then
scbVert.Max = picData2.Height - ScaleHeight
scbVert.LargeChange = scbVert.Max / 10
scbVert.SmallChange = scbVert.Max / 20
scbVert.value = picData2.Top
Else
picData2.Top = 0
End If
end sub
Private Sub scbVert_Change()
On Error GoTo ErrTrap
' Initializations
If Not scbVert.Visible Then GoTo Done
' Body
picData2.Top = -scbVert.value
end sub
the same for scroll event.
When scroll bar and picdata2 has the top=0 (scroll bar value is 0) it works fine,
when I move scroll bar down and resize form i get this error.

Please help. Thanks.

 
I think the problem is this line:

scbVert.value = picData2.Top

in the picData_Resize() event. If you move the scrollbar down, that makes the Top property of picData2 have a negative value. You then try to assign a negative value to the sbcVert.Value property, and it cannot have a negative value. Try this instead:

If picData2.Top < 0 Then
scbVert.value = -picData2.Top
Else
scbVert.value = picData2.Top
EndIf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top