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.

298 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

EXAMPLE 4<br />

The following program allows the user to select the text size in a text box. The three option buttons have<br />

been attached to the frame with the single-click-draw technique.<br />

Private Sub opt12pt_Click()<br />

txtInfo.Font.Size = 12<br />

End Sub<br />

Private Sub opt18pt_Click()<br />

txtInfo.Font.Size = 18<br />

End Sub<br />

Private Sub opt24pt_Click()<br />

txtInfo.Font.Size = 24<br />

End Sub<br />

Object Property Setting<br />

frmSize Caption Change Size<br />

fraFontSize Caption Font Size<br />

opt12pt Caption &12<br />

opt18pt Caption 1&8<br />

opt24pt Caption &24<br />

txtInfo Text Hello<br />

[Run, <strong>and</strong> click on the last option button (or press Alt+2).]<br />

A single form can have several groups of option buttons. However, each group must be<br />

attached to its own frame or picture box, or to the form itself.<br />

THE HORIZONTAL AND VERTICAL SCROLL BAR CONTROLS<br />

Figure 10-4 shows the two types of scroll bars. When the user clicks on one of the arrow buttons,<br />

the thumb moves a small amount toward that arrow. When the user clicks between the<br />

thumb <strong>and</strong> one of the arrow buttons, the thumb moves a large amount toward that arrow. The<br />

user can also move the thumb by dragging it. The main properties of a scroll bar control are<br />

Min, Max, Value, SmallChange, <strong>and</strong> LargeChange, which are set to integers. At any time,<br />

hsbBar.Value is a number between hsbBar.Min <strong>and</strong> hsbBar.Max determined by the position of<br />

the thumb. If the thumb is halfway between the two arrows, then hsbBar.Value is a number<br />

halfway between hsbBar.Min <strong>and</strong> hsbBar.Max. If the thumb is near the left arrow button, then<br />

hsbBar.Value is an appropriately proportioned value near hsbBar.Min. When an arrow button<br />

is clicked, hsbBar.Value changes by hsbBar.SmallChange <strong>and</strong> the thumb moves accordingly.<br />

When the bar between the thumb <strong>and</strong> one of the arrows is clicked, hsbBar.Value changes by<br />

hsbBar.LargeChange <strong>and</strong> the thumb moves accordingly. When the thumb is dragged,

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

Saved successfully!

Ooh no, something went wrong!