Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Select Case Statements and Selection Input.
Advertisements

Visual Basic.NET BASICS Lesson 10 Do Loops. 2 Objectives Explain what a loop is. Use the Do While and Do Until loops. Use the InputBox function. Use the.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic.NET, Second Edition.
CSC110 Fall Chapter 5: Decision Visual Basic.NET.
Promoting Code Reuse Often in programming, multiple procedures will perform the same operation IN OTHER WORDS – the same piece of code will do the same.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
OF COURSE I DON'T LOOK BUSY... I DID IT RIGHT THE FIRST TIME
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Chapter 1 Mr. Wangler.
05/09/ Introducing Visual Basic Sequence Programming.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Chapter 8: Writing Graphical User Interfaces
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Five More on the Selection Structure.
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Visual Basic .NET BASICS
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Five More on the Selection Structure.
Visual Basic.NET BASICS Lesson 3 Events and Code.
Visual Basic.net Textbox & Label Controls. Textbox Naming convention (txt) Primary use (user input) Can except numeric and character values.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
Programming with Microsoft Visual Basic th Edition
1.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
JavaScript, Fourth Edition
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Chapter 3 Control Structures. The If…Then Statement The If…Then statement is a Decision statement = that executes a set of statements when a condition.
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes.
Adding Code to the Option Button. Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to.
Chapter Five More on the Selection Structure Programming with Microsoft Visual Basic th Edition.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.
Using Forms and Form Elements In Visual Basic.NET.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub.
3.02 APPLY PROPERTIES ASSOCIATED WITH THE CONTROLS Computer Programming I.
Visual Basic.NET Windows Programming
Chapter 1: An Introduction to Visual Basic 2015
Chapter Topics 15.1 Graphical User Interfaces
Chapter 8: Writing Graphical User Interfaces
3.01 Apply Controls Associated With Visual Studio Form
CHAPTER FIVE Decision Structures.
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 Visual Basic Interface
Microsoft Visual Basic 2005 BASICS
CHAPTER FIVE Decision Structures.
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Items, Group Boxes, Check Boxes & Radio Buttons
Group Boxes, Radio buttons and Checked List Boxes
CHAPTER FOUR VARIABLES AND CONSTANTS
Presentation transcript:

Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons

2 Objectives Use nested If statements. Use radio buttons. Use the form Load event. Use the Select Case statement.

3 Using Nested If Statements When you place an If statement inside another If statement, the If statement inside is called a nested If statement. When using nested If statements, it is important that you properly indent the code.

4 Using Radio Buttons Radio buttons are similar to check boxes with one important difference.  Radio Buttons appear in groups, and only one button in the group can be selected at a time. To successfully use radio buttons, there are three steps involved:  Create a GroupBox to group the radio buttons.  Create the radio buttons in the GroupBox.  Write code to use the radio buttons.

5 Creating a GroupBox Control A GroupBox control is a container for other controls. The controls that you place inside a GroupBox are treated as one unit. Radio buttons in a GroupBox are sometimes referred to as an option group.

6 Creating Radio Buttons in the GroupBox Now that the GroupBox is created, the next step is to add radio buttons to the GroupBox. Like other controls, radio buttons need to be named appropriately using the Name property.

7 Adding Code to the Radio Buttons Coding radio buttons requires that you think in an event-driven way. Use form-level variables as the scope to keep track of the option that has been selected.

8 Using a Form Load Event Procedure By setting the Checked property of a radio button to True, the radio button is selected. When a form is loaded and opened by the program, a special event called a Load event is triggered. Like other events, you can write an event procedure for the form’s Load event.

9 Using Select Case In a Select Case statement, you specify a variable to test and then list a number of cases for which you want to test. The first line in a Select Case statement specifies the piece of data that is involved in the decision. You can use conditional operators in a Case statement as well.

10 Setting Additional Properties The BackColor property sets the form’s background color. The Location property allows you to specify the location of an object using X and Y coordinates.

11 Summary If statements can be nested to make addi- tional decisions within the code of the If statement. It is important to indent the code in a nested If statement to make the code readable. Each If statement within a nested If statement must end with the End If statement. Radio buttons appear in groups. Only one radio button in the group can be selected at a time. Radio buttons are sometimes called option buttons.

12 Summary (continued) The first step in creating a group of radio buttons is to create a GroupBox control to contain the radio buttons. The controls within a GroupBox are treated as one unit. The Text property of a GroupBox control specifies the text that appears at the top of the GroupBox.

13 Summary (continued) To associate a radio button with a GroupBox, you must click the RadioButton tool only once and draw the radio button in the GroupBox. If you double-click to create a radio button, it will not associate itself with the GroupBox. The Text property of a radio button specifies the text that appears on the label attached to the radio button.

14 Summary (continued) Coding radio buttons involves using form- level variables that carry values that reflect the selected radio. A form’s Load event procedure is executed each time a form is loaded and opened by the program.

15 Summary (continued) The Select Case statement allows you to make multi-way selections. The Case state- ments in a Select Case can test a range or use conditional operators. Conditional operators in a Case statement must include the Is keyword. As a default, the Case Else statement is applied if no other Case is True.