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.

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

9. Click on the Left Arrow button. (This causes the next item to appear flush left<br />

to indicate that it is a top-level menu item.)<br />

10. Type &Size into the Caption box <strong>and</strong> type mnuSize into the Name box.<br />

11. Click on the Next button <strong>and</strong> then click on the Right Arrow button.<br />

12. Type 12 into the Caption box <strong>and</strong> type mnu12 into the Name box.<br />

13. Click on the Next button.<br />

14. Type 24 into the Caption box <strong>and</strong> type mnu24 into the Name box. Your Menu<br />

Editor window should now appear as in Figure 10-12.<br />

15. Click the OK button to close the Menu Editor window.<br />

Three of the check boxes on the Menu Editor window are especially useful. When the<br />

Checked box is checked, a checkmark appears in front of the menu item. This checkmark can<br />

be altered in code with statements such as mnuItem.Checked = False <strong>and</strong> mnuItem.Checked<br />

= True. When the Enable box is unchecked, the menu item appears gray <strong>and</strong> does not respond<br />

to the click event. The enabled state can be altered in code with statements such as mnu-<br />

Item.Enabled = False <strong>and</strong> mnuItem.Enabled = True. When the Visible property is unchecked,<br />

the menu item is invisible.<br />

EXAMPLE 3<br />

The following program creates the application in Figure 10-11, in which the menu is used to alter the<br />

appearance of the contents of a text box. The form has caption “Alter Font & Size” <strong>and</strong> the properties of<br />

the menu items are as created before.<br />

Private Sub mnu12_Click()<br />

txtInfo.Font.Size = 12<br />

End Sub<br />

Private Sub mnu24_Click()<br />

txtInfo.Font.Size = 24<br />

End Sub<br />

Private Sub mnuCourier_Click()<br />

txtInfo.Font.Name = “Courier”<br />

End Sub<br />

Private Sub mnuTimesRm_Click()<br />

txtInfo.Font.Name = “Times New Roman”<br />

End Sub<br />

■ THE CLIPBOARD OBJECT<br />

The clipboard object is used to copy or move text from one location to another. It is maintained<br />

by Windows <strong>and</strong> therefore even can be used to transfer information from one Windows application<br />

to another. It is actually a portion of memory that holds text <strong>and</strong> has no properties<br />

or events.<br />

If str is a string, then the statement<br />

Clipboard.SetText str<br />

replaces any text currently in the clipboard with str. The statement<br />

str = Clipboard.GetText()<br />

assigns the text in the clipboard to the string variable str.<br />

The statement

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

Saved successfully!

Ooh no, something went wrong!