Я бы только не так
| Код | Private Sub VScroll1_Change() Label1.Top = -VScroll1.Value End Sub
|
сделал, а так
| Код | Private Sub VScroll1_Scroll() Label1.Top = -VScroll1.Value End Sub
|
Так красивее... 
Добавлено @ 01:05 А вот другой прикольный вариант.
Код в форме:
| Код | Option Explicit
' You have a royalty-free right to use, modify, reproduce and distribute ' the Sample Application Files (and/or any modified version) in any way ' you find useful, provided that you agree that Martin Liss has no warranty, ' obligations or liability for any Sample Application Files.
' All objects that should scroll must be drawn in picI_Scroll
' If you need to edit any of the objects that are below the bottom of the form, ' temporarily change picI_Scroll.Top to -1000, -10000, or whatever it takes
Public Disclaimer
Private Sub cmdExit_Click()
Unload Me Set frmScroll = Nothing End Sub
Private Sub Form_Activate()
' So that scrooling will happen if the user immediately presses ' PageUp or PageDown picI_Scroll.SetFocus End Sub
Private Sub Form_Load()
picWindow.Left = 0 picWindow.Width = Me.Width - VScroll1.Width VScroll1.Height = picWindow.Height VScroll1.Max = picI_Scroll.Height - picWindow.Height VScroll1.SmallChange = 100 VScroll1.LargeChange = picWindow.Height VScroll1.Left = Me.Width - VScroll1.Width - 60 VScroll1.Top = 0 picI_Scroll.Left = 0 picI_Scroll.Width = picWindow.Width End Sub
Public Sub CheckKeyCode(KeyCode As Integer) '*************************************************************************** 'Purpose: Intercept and act on special keys on me so ' that up and down arrows and scroll bar works as expected. Also ' automatically scroll screen when Tab key would otherwise disappear ' off the screen. 'Inputs: KeyCode - The ASCII(?) value of the key pressed 'Outputs: None '***************************************************************************
Dim nScrollValue As Double Dim nOnePage As Integer nOnePage = Me.VScroll1.Height If KeyCode = vbKeyPageUp Or KeyCode = vbKeyPageDown Then If KeyCode = vbKeyPageDown Then nScrollValue = -Me.picI_Scroll.Top + nOnePage Else nScrollValue = -Me.picI_Scroll.Top - nOnePage End If 'Make sure that the scroll bar 'handle' is not attempted to be positioned 'below the bottom of the scroll bar. If nScrollValue > Me.VScroll1.Max Then nScrollValue = Me.VScroll1.Max Me.picI_Scroll.Top = -Me.VScroll1.Max End If If nScrollValue > 0 Then Me.VScroll1.Value = nScrollValue Else Me.VScroll1.Value = 0 End If End If End Sub
Private Sub picI_Scroll_KeyDown(KeyCode As Integer, Shift As Integer)
CheckKeyCode KeyCode End Sub
Private Sub VScroll1_Change()
picI_Scroll.Top = -(VScroll1.Value) ' So that the scrollbar doesn't blink cmdExit.SetFocus
End Sub
|
Пример взят на: www.vbforums.com |