Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.

Slides:



Advertisements
Similar presentations
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Advertisements

Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
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.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
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.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Chapter 1 Mr. Wangler.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005: Reloaded Second Edition
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
© 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.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Using Visual Basic for Applications (VBA) – Project 8.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Visual Basic.NET BASICS Lesson 3 Events and Code.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Introduction to Programming with RAPTOR
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Exceptions, handling exceptions & message boxes Year 11 Information Technology.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
5.01 Understand Different Types of Programming Errors
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
More Visual Basic!. Creating a Standalone Program A standalone program will allow you to make a program file that can be run like other Windows programs,
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.
Visual Basic .NET BASICS
Visual Basic.NET Windows Programming
Java Exceptions a quick review….
5.01 Understand Different Types of Programming Errors
Microsoft Access Illustrated
Using Procedures and Exception Handling
Microsoft Visual Basic 2005 BASICS
Variables and Arithmetic Operations
5.01 Understand Different Types of Programming Errors
Microsoft Visual Basic 2005 BASICS
Hands-on Introduction to Visual Basic .NET
Part B – Structured Exception Handling
Microsoft Visual Basic 2005 BASICS
Presentation transcript:

Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling

2 Objectives Use the exponentiation operator to raise numbers to a power. Describe the order of operations. Use the Visible property to enhance output. Describe the purpose of comments in programs.

3 Objectives (continued) Handle run-time errors using the Try/Catch structure. Display messages using the MsgBox function. Control program flow using the Exit Sub statement.

4 Exponentiation Exponentiation is the process of raising a number to a power. The symbol that represents exponentiation is the caret (^). The operator raises the number to the left of the operator to the power that appears on the right of the operator.

5 Order of Operations From your math classes, you may recall the rules called the order of operations. Visual Basic.NET uses the same set of rules for its calculations. Visual Basic.NET allows you to use parentheses to override the order of operations.

6 Using the Visible Property to Enhance Output You have used the Visible property to make an image appear and disappear. Another example of a useful application of the Visible property is preventing labels from appearing until you are ready for the user to see the label. By initially setting the Visible property to False, the output will remain invisible until you make the labels visible in the code.

7 Using Comments The Properties window allows you to easily alter the properties of objects. Two of the most important properties of a form are the Text and Name properties.  The Text property specifies the text that appears in the title bar.  The Name property names the object for coding.

8 Handling Run-Time Errors Users will enter all kinds of unexpected data or fail to enter required data. These are exceptions or run-time errors. Run-time errors are not detected at the time the program is compiled because the error is caused by conditions that do not exist until the program is running. When a run-time error occurs, the system throws an exception.

9 Trapping Run-Time Errors with the Try/Catch Structure Visual Basic.NET allows you to write code that will executed when a run-time error occurs. To specify what code will execute when an error occurs, you must turn on error trapping. To turn on error trapping, place a Try statement above the code that may generate a run-time error. The code that will be executed if an error occurs is often called an error handler.

10 Using MsgBox One of the easiest ways to display a message of your own, such as an error message, is to use the MsgBox function. The MsgBox function causes a dialog box to pop up, displaying a message that you specify.

11 Using End Sub to Exit a Subroutine The Exit Sub statement forces the event procedure to end, regardless of whether there is more code in the procedure. The procedure will end when the flow of execution reaches the Exit Sub statement and can be placed anywhere in the subroutine. This allows the programmer to exit the subroutine for different reasons.

12 Summary The exponential operator (^) raises a number to a power. The rules that dictate the order that math operators are applied in a formula are called the order of operations. Parentheses can be used to override the order of operations. The Visible property can be used to hide a label until you are ready for the user to see it.

13 Summary (continued) The apostrophe is used to add comments to Visual Basic. NET code. Comments allow you to keep track of changes in code and explain the purpose of code. Comments are often called internal documentation. Errors that occur while a program is running are called run-time errors or exceptions. Visual Basic. NET allows you to trap errors, using Try/Catch, and execute special code that you specify to handle the error.

14 Summary (continued) The MsgBox function pops up a dialog box, delivering a message to the user. When you detect errors that cannot be completely handled, you should send the user a message and use the Exit Sub to end the event procedure before the error can cause additional problems.