CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
 Control structures  Algorithm & flowchart  If statements  While statements.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
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.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1A) UTPA – Fall 2011.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 12: How Long Can This Go On?
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Repetition Statements
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Introduction to Problem Solving and Control Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
Controlling Program Flow with Looping Structures
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 6 Controlling Program Flow with Looping Structures.
1 Chapter 4 - Control Statements: Part 1 Outline 4.1 Introduction 4.4 Control Structures 4.5 if Selection Structure 4.6 if/else Selection Structure 4.7.
Chapter 6 JavaScript: Introduction to Scripting
Visual Basic 6 (VB6) Data Types, And Operators
2.5 Another Java Application: Adding Integers
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Chapter 3: Introduction to Problem Solving and Control Statements
Chapter (3) - Looping Questions.
T. Jumana Abu Shmais – AOU - Riyadh
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
3 Control Statements:.
CIS 16 Application Development Programming with Visual Basic
Introduction to Problem Solving and Control Statements
CSCI 3327 Visual Basic Review: Exam I
Introduction to Programming
CSCI 3328 Object Oriented Programming in C# Review: Exam I
Presentation transcript:

CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011

Objectives In this chapter, you will do exercises related to: –Primitive data types in Visual Basic –Arithmetic operators –Algorithm design –Usage of control structures in Visual Basic 2

Compound Assignment Operators Value = Value + 3  Value +=3 More compound assignment operators – += – -= – *= – /= – \= – ^= – &= 3

Example 3.8: Addition.vb URL: p_2010/codeexamples.html p_2010/codeexamples.html TextBox –Change the names of controls E.g., resultLabel, number1TextBox, number2TextBox, addButton –resultLabel.Text = "The sum is" & total –TextChanged Events –Clear() method 4

Exercises The form's _____ property specifies the text that is displayed in the Form's title bar. –1. Title 2. Text 3. (Name) 4. Name Property _____ specifies how text is aligned within a Label's boundaries –1. Alignment 2. AlignText 3. Align 4. TextAlign An output Label should ______. –1. be distinguishable from other Labels –2. initially have an empty Text property or a default value –3. use Fixed3D for the BorderStyle property –4. All of the above A Button's ______ property sets the text on the face of the Button. –1. Name 2. Text 3. Title 4. Face If there are errors in an application, they appear in a window known as the _____. –1. TaskList 2. Output 3. Properties 4. Error List 5

Exercises (cont'd) When a value is placed into a memory location, the value ______ the previous value in that location. –1. copies 2. replaces 3. adds itself to 4. moves When a value is read from memory, that value is _____. –1. overwritten 2. replaced with a new value 3. moved to a new location in memory 4. not overwritten Arithmetic expressions must be written ___to facilitate entering applications into the computer. –1. using parentheses 2. on multiple lines 3. in straight-line form 4. None of the above The expression to the right of an assignment operator (=) is evaluated ______the assignment occurs. –1. before 2. after 3. at the same time 4. none of the above 6

True/False Statements Comments cause the computer to print the text after the ' on the screen when the program executes. All variables must be declared before they can be used in a Visual Basic program. Visual Basic considers the variable names number and NuMbEr to be different. The arithmetic operators *, /, + and – all have the same level of precedence. A string of characters contained between double quotation marks is called a phrase or phrase literal. Integer division yields an Integer result. 7

What Does the Code Do? Dim number1 As Integer Dim number2 As Integer Dim result As Integer number1 = 5*(4+6) 'What is number1? number2= 2^2 'What is number2? result =number1 \ number2 'What is result? 8

What is Wrong in the Code? Dim number1 As Integer Dim number2 As Integer Dim result As Integer number1 = (4*6^4)/(10 Mod 4 - 2) number2=(16\3)^2*6+1 result =number1-number2 9

Exercises A(n) ______ is a plan for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed. –1. chart 2. control structure 3. algorithm 4. ordered list ____ is an informal language that helps you develop algorithms. –1. Pseudocode 2. VB-Speak 3. Notation 4. None of the above Pseudocode_____. –1. usually describes only declarations 2. is executed on computers 3. usually describes only executable lines of code 4. usually describes declarations and executable lines of code All Visual Basic applications can be written in terms of ___ types of control structures. –1. one 2. two 3. three 4. four 10

Exercises (cont'd) The process of application statements executing one after another in the order in which they are written is called_______. –1. transfer of control 2. sequential execution 3. workflow 4. none of the above The symbol _____ is not a Visual Basic operator. –1. * 2. ^ 3. % 4. <> If … Then …Else is a ______-selection statement. –1. single 2. double 3. triple 4. nested If "number" is initialized with the value 5, what value will "number" contain after the expression: number-=3 executes? –

Exercises (cont'd) The body of a Do While … Loop statement executes ______. –1. at least once 2. never 3. while its condition is true 4. while its condition is false Statements in the body of a Do until … Loop execute repeatedly for as long as the _____ remains False. –1. loop-continuation condition 2. do-loop condition 3. loop-termination condition 4. until-loop condition 12

Exercises (cont'd) Identify errors in the code that totals the values from 1 to 50, assuming that value is 50. –Do While value >=0 – sum+=value –Loop 13

Exercises (cont'd) Write a repetition structure that obtains 2^10 (DO NOT use ^ directly). 14

True/False Statements Pseudocode is a structured programming language. The body of a Do While … Loop is executed only if the loop-continuation test is false. The body of a While … End While is executed only if the loop-continuation test is false. The body of a Do Until … Loop is executed only if the loop-termination test is false. 15

Exercises After the Class Chapters 1~4 in your textbook –Self-Review Exercises –Quick Quiz –Exercises 16