Presentation is loading. Please wait.

Presentation is loading. Please wait.

McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls.

Similar presentations


Presentation on theme: "McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls."— Presentation transcript:

1 McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls

2 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 2 McGraw-Hill/Irwin More Controls Introducing more controls Working with multiple controls Designing your applications for user convenience Coding for the controls Programming hints

3 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 3 McGraw-Hill/Irwin Introducing More Controls Labels: lblName.Caption=txtName.Text Text boxes: txtName.Text=“French” Frames: Groups option buttons Check boxes: chkName.Value=0, 1 or 2.caption is name Option buttons: optButton.value=True or False Images

4 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 4 McGraw-Hill/Irwin Tools Introduced in Chapter 2 Check box Frame Shape Image Option button Text box Line

5 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 5 McGraw-Hill/Irwin Text Boxes Default property is.Text –txtLastName = “Frockmeister” sets.Text prop. Alignment property –0 (left) –1 (right) –2 (center) The Multiline property must be true, otherwise the alignment is ignored.

6 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 6 McGraw-Hill/Irwin Frames Frames are containers for option buttons and check boxes Frames establish the mutually exclusive nature of buttons: Frame Option buttons

7 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 7 McGraw-Hill/Irwin Check Boxes Select or deselect Yes/No options Default property is.Value Example: chkPrint.Value = 0 (no) 0 = no, 1 = yes (checked), 2=disabled check box

8 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 8 McGraw-Hill/Irwin Option Buttons Used for mutually exclusive choices such as color choices or Print All, Print Selection, or Print One Page Default property is.Value (0 or 1) Names: optBlue, optFontSize Option buttons

9 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 9 McGraw-Hill/Irwin Images An image holds a picture (not an OLE object) Properties: –.Picture (the file name of an image to display) –.Stretch (picture fills control) –.Visible (true/false makes it appear/disappear) Example: imgFlag.Visible = False

10 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 10 McGraw-Hill/Irwin Shape Control Shape control places rectangles, squares, ovals, circles, or other shapes on a form Shape is determined by.Shape property Shape property value

11 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 11 McGraw-Hill/Irwin Line Control Draw lines on a form to separate elements Name example: linLogo A Line has very few properties: –BorderStyle –BorderWidth –BorderColor

12 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 12 McGraw-Hill/Irwin Working with Multiple Controls Selecting multiple controls Deselecting a group of controls Moving controls as a group Setting properties for multiple controls Aligning controls

13 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 13 McGraw-Hill/Irwin Designing Your Applications for User Convenience Designing the user interface Defining keyboard access keys (Exit) Setting command button Default and Cancel properties.Default = True or False.Cancel = True or False Setting the tab order property of controls –TabStop property (.Enabled = yes) –TabIndex property (a value beginning at 0)

14 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 14 McGraw-Hill/Irwin Coding for the controls Clearing text boxes and labels Resetting the focus Setting option buttons/check boxes value properties Changing the font Properties of controls Changing multiple properties of a control Continuing program lines

15 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 15 McGraw-Hill/Irwin Controls' Default Properties Each control has a default property A default property is the implied property for the object if you omit it following the object: –txtAddress = "1234 Somewhere Street" –chkPrint = True –lstChoice(index) = "14"

16 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 16 McGraw-Hill/Irwin Programming Hints Check the tab order of an application Use the value property of a check box or option button to set other true/false properties. Ctrl-click a tool to repeatedly use tool Create an option button inside its frame Label controls are “read only” messages Text controls are input/output controls

17 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 17 McGraw-Hill/Irwin Review Questions - 1 of 2 1. You can display program output in a text box or a label. When should you use a text box? When should you use a label? 2. How does the behavior of option buttons differ from the behavior of check boxes? 3. If you want two groups of option buttons on a form, how can you make the groups operate independently? 4. Explain how to make a graphic appear in an image control. 5. Describe how to select several labels and set them all to 12-point font size in on operation [at design time]. 6. What is the purpose of keyboard access keys? How can you define them in your project? How do they operate at run time? 7. Explain the purpose of the Default and Cancel command button properties. 8. What is the focus? How can you control which object has the focus?

18 Programming in Visual Basic 6.0 Update Edition © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 18 McGraw-Hill/Irwin Review Questions - 2 of 2 9. How do you force the insertion point appear in a particular text box that may not have the lowest tabindex value? 10. Write the statement to force the focus to be on txtFirstName on a form. 11. What Basic statements will clear the current contents of a text box and a label? 12. Explain how to change a label's Caption to italic at design time and at run time. 13. How are the With and End statements used? Give an example. 14. What is concatenation and when would it be useful? 15. Explain how to continue a very long Basic statement onto another line. 16. What is the default property of a control? Give an example.


Download ppt "McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls."

Similar presentations


Ads by Google