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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB scroller and common dialog PROBLEM!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have a vert. scroll bar on a form using the below code. V scroller worked great until I added a common dialog box. Problem: When I run my exe and try using the vert. scroll. I rec' the following error message " 'Top' property cannot be read at run time." debug hi lites the follow code: "ctl.Top = ctl.Top + VPos - VScroll1.Value"
Without the dlg the vscroller works fine. Without vscroll the dlg works fine. Any help would be greatly appreciated.

vscroll code:

Dim VPos As Integer

Private Sub VScroll1_Change()
Call ScrollForm(0)
End Sub

Private Sub VScroll1_Scroll()
Call ScrollForm(0)
End Sub

Public Sub ScrollForm(Direction As Byte)
Dim ctl As Control

'Scroll Vertically
If Direction = 0 Then
For Each ctl In Me.Controls
'Make sure it's not a ScrollBar
If Not (TypeOf ctl Is VScrollBar) Then
'If it's a Line then
If TypeOf ctl Is Line Then
ctl.Y1 = ctl.Y1 + VPos - VScroll1.Value
ctl.Y2 = ctl.Y2 + VPos - VScroll1.Value
Else
ctl.Top = ctl.Top + VPos - VScroll1.Value
End If
End If
Next
VPos = VScroll1.Value
End If
End Sub
 
for each x in controls will also try to move your common dlg ctrl. I guess that we can't move controls like timers and common dlg in run time.

You can try to replace the line:
If Not (TypeOf ctl Is VScrollBar) Then
by:
If Not (TypeOf ctl Is VScrollBar or TypeOf ctl Is CommonDialog) Then

good luck :)
 
Salhm,

Thanks for the input it worked. Once I read your code I knew I forgot to put in the typeof command. Thanks

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top