Bewerken

Delen via


ScrollBars property

Specifies whether a control, form, or page has vertical scroll bars, horizontal scroll bars, or both.

Syntax

object.ScrollBars [= fmScrollBars ]

The ScrollBars property syntax has these parts:

Part Description
object Required. A valid object.
fmScrollBars Optional. Where scroll bars should be displayed.

Settings

The settings for fmScrollBars are:

Constant Value Description
fmScrollBarsNone 0 Displays no scroll bars (default).
fmScrollBarsHorizontal 1 Displays a horizontal scroll bar.
fmScrollBarsVertical 2 Displays a vertical scroll bar.
fmScrollBarsBoth 3 Displays both a horizontal and a vertical scroll bar.

Remarks

If the KeepScrollBarsVisible property is True, any scroll bar on a form or page is always visible, regardless of whether the object's contents fit within the object's borders.

If visible, a scroll bar constrains its scroll box to the visible region of the scroll bar. It also modifies the scroll position as needed to keep the entire scroll bar visible. The range of a scroll bar changes when the value of the ScrollBars property changes, the scroll size changes, or the visible size changes.

If a scroll bar is not visible, you can set its scroll position to any value. Negative values and values greater than the scroll size are both valid.

For a single-line control, you can display a horizontal scroll bar by using the ScrollBars and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

  • When ScrollBars is set to fmScrollBarsNone, no scroll bar is displayed.

  • When ScrollBars is set to fmScrollBarsHorizontal or fmScrollBarsBoth, the control displays a horizontal scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar underneath its edit region.

  • When AutoSize is True, the control enlarges itself to accommodate the addition of a scroll bar unless the control is at or near its maximum size.

For a multiline TextBox, you can display scroll bars by using the ScrollBars, WordWrap, and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

  • When ScrollBars is set to fmScrollBarsNone, no scroll bar is displayed.

  • When ScrollBars is set to fmScrollBarsVertical or fmScrollBarsBoth, the control displays a vertical scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar at the right edge of its edit region.

  • When WordWrap is True, the multiline control will not display a horizontal scroll bar. Most multiline controls don't use a horizontal scroll bar.

  • A multiline control can display a horizontal scroll bar if the following conditions occur simultaneously:

    • The edit region contains a word that is longer than the edit region's width.
    • The control has enabled horizontal scroll bars.
    • The control has enough room to include the scroll bar under the edit region.
    • The WordWrap property is set to False.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.