Items, Group Boxes, Check Boxes & Radio Buttons

Slides:



Advertisements
Similar presentations
Getting Started with PowerPoint
Advertisements

CS0004: Introduction to Programming Select Case Statements and Selection Input.
© by Pearson Education, Inc. All Rights Reserved. continued …
Automating Tasks With Macros
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Automating Tasks with Macros. Macro Essentials  A macro is a list of actions that happen when you run the macro.  Creating a Macro: − Choose Create.
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
Visual Basic Chapter 1 Mr. Wangler.
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
05/09/ Introducing Visual Basic Sequence Programming.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Decisions with Select Case and Strings Chapter 4 Part 2.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Copyright © Don Kussee 1410-Ch5 #1031 CNS 1120 Chapter 5 Selection statements 1120-Ch5.PPT.
PowerPoint Basics Tutorial 2: A Slide Show In this tutorial you’re going to create a presentation from scratch. You will have to keep this presentation.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 5 Decision Making.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
More Visual Basic Code: if-then-else, for loops Controls: Multiple forms, List Boxes, Radio buttons, frames,
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
How to Create a Power Point Presentation. Topics that will be covered: 1) Getting Started 2) Common Features 3) Working with Text 4) Working with Graphics.
CONDITIONAL FORMATTING AND CUSTOM NUMBER FORMATS LEC 5 1.
Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.
Computer Science Up Down Controls, Decisions and Random Numbers.
Desktop Publishing Lesson 1 — Working with Documents.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Visual Basic.NET Windows Programming
MOM! Phineas and Ferb are … Aims:
Scratch for Interactivity
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
CHAPTER FIVE Decision Structures.
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 Visual Basic Interface
© Paradigm Publishing, Inc.
Understanding Microsoft Excel
MIS 3200 – Unit 4 Complex Conditional Statements else if switch.
Conditions and Ifs BIS1523 – Lecture 8.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Simple Windows Applications
Building an Application in the Visual Basic .NET Environment
Project Design, Forms and Buttons
Blackboard Committee 2017 Bb Training Program
Lesson 1 – PowerPoint Essentials
Selection Statements Chapter 3.
Microsoft Office Illustrated Fundamentals
Chapter 1 Introducing Small Basic
Web Programming and Design
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Items, Group Boxes, Check Boxes & Radio Buttons Computer Science Items, Group Boxes, Check Boxes & Radio Buttons

Icons Using the Icon property of the form, you can change this displayed icon to something a little flashier.

TASK: Create your own Icon Do this using Icon Edit 32x32 pixels are 8 times as large You can draw single points, lines, open rectangles and ovals, and filled rectangles and ovals. Once completed, the icon file can be saved for attaching to a form. Once you have finished your icon, save it. Click File, then Save. Icon files are special graphics files saved with an ico extension. Teacher resource Sandwich.ico which is in the IconEdit folder.

Assigning Icons to Forms Start Visual Basic Express and start a new project. A blank form should appear. Go to the properties window and click on the Icon property. An ellipsis (...) button appears. Click that button and a window that allows selection of icon files will appear.

Group Box Control A group box is simply a control that can hold other controls. Group boxes provide a way to separate and group controls and have an overall enable/disable feature. This means if you disable the group box, all controls in the group box are also disabled. The group box has no events, just properties. In Toolbox: On Form (default properties):

Placing Controls in a Group Box Place controls directly in the group box using any of the usual methods. Draw controls outside the group box and drag them in. Copy and paste controls into the group box (prior to the paste operation, make sure the group box is selected).

TASK: Group Boxes Start a new project. Put a group box on the form and resize it so it is fairly large. Select the button control in the Visual Basic Express toolbox. Drag the control until it is over the group box. Drop the control in the group box. Put a second button in the group box. Put a numeric updown control in the group box. Notice how the controls are associated with the group box. Run the project. Notice you can click on the buttons and use the numeric updown control. Stop the project.

TASK: Group Boxes Set the group box Enabled property to False. Run the project again. Notice the group box title (set by the Text property) is grayed and all of the controls on the group box are now disabled - you can’t click the buttons or updown control. Hence, by simply setting one Enabled property (that of the group box), we can enable or disable a number of individual controls. Stop the project. Reset the group box Enabled property to True. Set the Visible property to False (will remain visible in design mode). Run the project. The group box and all its controls will not appear. You can use the Visible property of the group box control to hide (or make appear) some set of controls (if your project requires such a step). Stop the project.

TASK: Group Boxes Change the Visible property back to True. Place a label control in the group box. Change the BackColor property of the group box. Notice the background color of the label control takes on the same value, while the button controls are unaffected. Recall this is because the group box is a ‘container’ control. Sometimes, this sharing of properties is a nice benefit, especially with label controls. Other times, it is an annoyance. If you don’t want controls to share properties (BackColor, ForeColor, Font) with the group box, you must change the properties you don’t like individually.

Check Box Control A check box provides a way to make choices from a group of things. When a check box is selected, a check appears in the box. Toolbox: On Form (default properties):

TASK: Check Boxes Start a new project. Draw a group box. Place three or four check boxes in the group box Move the group box to make sure the check boxes are in the group box. Run the project. Click the check boxes and see how the check marks appear and disappear. Notice you can choose as many, or as few, boxes as you like. In code, we would examine each check box’s Checked property to determine which boxes are selected. Stop the project. Change the BackColor of the group box. Notice the check box controls’ background color changes to match.

Radio Button Control A radio button provides a way to make a “mutually-exclusive” choice from a group of things. Radio buttons always work in groups and each group must be in a separate group box control. In Toolbox: On Form (default properties):

TASK: Radio Buttons Start a new project. Draw a group box. Place three or four radio buttons in the group box. Set one of the buttons Checked property to True. Run the project. Notice one button has a filled circle. Click another radio button. That button will be filled while the previously filled button will no longer be filled. Keep clicking buttons to get the idea of how they work. Change the group box BackColor property and notice all the ‘contained’ radio buttons also change background color.

TASK: Radio Buttons Draw another group box on the form. Put two or three radio buttons in that group box and set one button’s Checked property to True. As always, make sure the buttons are properly placed in the group box. Run the project. Change the selected button in this second group. Notice changing this group of radio buttons has no effect on the earlier group. Remember that radio buttons in one group box do not affect radio buttons in another.

Decisions - Select Case The If/End If structure is a way of letting Visual Basic Express make decisions using comparison operators and logical operators. We could implement such a logic using If, ElseIf, and End If statements. As an example, say we want to do different things if the variable A is 0, 1, 2, 3, 4, or 5 The BASIC code, using an If/End If structure, to do this is: If A = 0 Then [BASIC code for A = 0] ElseIf A = 1 Then [BASIC code for A = 1] ElseIf A = 2 Then [BASIC code for A = 2] ElseIf A = 3 Then [BASIC code for A = 3] ElseIf A = 4 Then [BASIC code for A = 4] ElseIf A = 5 Then [BASIC code for A = 5] End If This code will work but there is a lot of repetition. It is also difficult to make simple changes to values A might have. BASIC offers another way to make decisions such as this.

Decisions - Select Case Select Case TestExpression Case Comparison1 [BASIC code to execute if Comparison1 matches TestExpression] Case Comparison2 [BASIC code to execute if Comparison2 matches TestExpression] Case Comparison3 [BASIC code to execute if Comparison3 matches TestExpression] Case Comparison4 [BASIC code to execute if Comparison4 matches TestExpression] Case Else [BASIC code to execute if no comparison matches TestExpression] End Select The Select Case statement is used to make decisions based on the value of a single variable or expression. A typical structure for the Select Case statement is: The TestExpression is any BASIC expression. Select Case goes through the list of Case statements, top to bottom, until it finds a Case where TestExpression matches the listed Case comparison. The BASIC statements associated with that particular Case are then executed and program execution moves to the first line after the End Select statement. If no match is found, the statements associated with Case Else are executed. If there is no Case Else and no match is found, none of the statements in the Select Case/End Select structure are executed. There is no limit to the number of Case statements allowed. What do the comparisons in the Case statements look like?

Decisions - Select Case The simplest comparison is just a single value against which TestExpression is tested for equality. For example, Case 6 would check to see if the TestExpression is equal to 6. You can use the To keyword to check against a range of values. For example, Case 6 To 14 checks to see if TestExpression is between 6 and 14 (inclusive). The Is keyword can be used with a comparison operator to make a logical comparison. For example, Case Is > 8 would check to see if TestExpression is greater than 8. Multiple comparison expressions can be used in one Case statement using commas as separators. The commas act like the Or logical operator. To see if TestExpression is between 2 and 4, between 8 and 12, or less than 2, we would use the Case statement: Case 2 To 4, 8 To 12, Is < 2 Whenever you are making multiple checks on a value of an expression, consider the Select Case statement instead of the If statement.

Decisions - Select Case As mentioned, you can have as many Case statements as you want. But, like the If/End If structure, only one section of BASIC code in a Select Case structure will be executed. This means that once BASIC has found a Case comparison that matches the Select Case expression, it will execute that section of code then leave the structure and execute the first line of code following the End Select statement. The rule for Select Case structures is: only the statements associated with the first matching Case will be executed.

Difference between IF and SELECT CASE If MyGuess = TheNumber Then [BASIC code for correct answer] ElseIf Math.Abs(MyGuess - TheNumber) <= 2 Then [BASIC code when burning up - within 2 of correct answer] ElseIf Math.Abs(MyGuess - TheNumber) <= 5 Then [BASIC code when hot - within 5 of correct answer] ElseIf Math.Abs(MyGuess - TheNumber) <= 15 Then [BASIC code when warm - within 15 of correct answer] ElseIf Math.Abs(MyGuess - TheNumber) <= 25 Then [BASIC code when cold - within 25 of correct answer] Else [BASIC code when freezing - more than 25 away] End If

Difference between IF and SELECT CASE Select Case Math.Abs(MyGuess - TheNumber) Case 0 [BASIC code for correct answer] Case Is <= 2 [BASIC code when burning up - within 2 of correct answer] Case Is <= 5 [BASIC code when hot - within 5 of correct answer] Case Is <= 15 [BASIC code when warm - within 15 of correct answer] Case Is <= 25 [BASIC code when cold - within 25 of correct answer] Case Else [BASIC code when freezing - more than 25 away] End Select