19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

hsbBar.Value changes accordingly. The default values of Min, Max, SmallChange, <strong>and</strong><br />

LargeChange are 0, 32767, 1, <strong>and</strong> 1, respectively. However, these values are usually reset at<br />

design time. Note: The setting for the Min property can be a number greater than the setting<br />

for the Max property. The Min property determines the values for the left <strong>and</strong> top arrows. The<br />

Max property determines the values for the right <strong>and</strong> bottom arrows.<br />

FIGURE 10-4 Horizontal <strong>and</strong> Vertical Scroll Bars<br />

The Change event is triggered whenever an arrow or bar is clicked, or after the thumb<br />

has been dragged. The Scroll event is triggered whenever the thumb is being dragged.<br />

EXAMPLE 5<br />

The following program uses scroll bars to move a smiling face around the form. The face is a large<br />

Wingdings character J inside a label. The values lblFace.Left <strong>and</strong> lblFace.Top are the distances in twips<br />

of the label from the left side <strong>and</strong> top of the form. (When printing, 1440 twips equal one inch; on the<br />

screen, 1440 twips are more or less an inch.)<br />

Private Sub hsbXPos_Change()<br />

lblFace.Left = hsbXPos.Value<br />

End Sub<br />

Private Sub vsbYPos_Change()<br />

lblFace.Top = vsbYPos.Value<br />

End Sub<br />

Object Property Setting<br />

frmFace Caption Smiling Face<br />

hsbXPos Min 0<br />

Max 3000<br />

SmallChange 100<br />

LargeChange 500<br />

Value 0<br />

vsbYPos Min 500<br />

Max 3000<br />

SmallChange 100<br />

LargeChange 500<br />

Value 500<br />

lblFace Caption J<br />

Font Wingdings<br />

Font Size 24<br />

Left 0<br />

Top 500<br />

Nine Elementary Controls 299

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!