Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Advertisements

1.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Microsoft Visual Basic: Reloaded Chapter Five More on the Selection Structure.
Val Function A Function performs an action and returns a value The expression to operate upon, known as the argument, (or multiple arguments), must be.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA By Robert T. Grauer Maryann Barber.
String Variables Visual Basic for Applications 4.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Input and Message Boxes. InputBox() Function An input box is a dialog box that opens and waits for the user to enter information. Syntax: InputBox(prompt[,title][,default])
CSC110 Fall Chapter 5: Decision Visual Basic.NET.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 4 Decisions and Conditions.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
3/9/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup 1 Introduction to VB6 Week 2.
Visual Basic Chapter 1 Mr. Wangler.
Dani Vainstein1 VBScript Session 9. Dani Vainstein2 What we learn last session? VBScript coding conventions. Code convention usage for constants, variables,
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Using the Select Case Statement and the MsgBox Function (Unit 8)
Chapter 4: The Selection Structure
Saeed Ghanbartehrani Summer 2015 Lecture Notes #4: Working with Variables and User Interfaces IE 212: Computational Methods for Industrial Engineering.
Intrinsic Functions Pre-coded Functions Used to improve developer productivity Broad Range of Activities Math calculations Time/Date functions String.
Chapter 4 P 1 Decisions and Conditions Control statements - seqeuncing - selection - repetition (picture later) - abstraction (procedure calls)
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
Chapter 4: The Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Chapter 4: The Selection Structure
Using Client-Side Scripts to Enhance Web Applications 1.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Five More on the Selection Structure.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Exploring Microsoft Access Chapter 8 Creating More Powerful Applications: Introduction to VBA.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Two Forms Please use speaker notes for additional information!
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
OV Copyright © 2011 Element K Content LLC. All rights reserved.  Determine the Dialog Box Type  Capture User Input Creating an Interactive Worksheet.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
ME 142 Engineering Computation I Input, Output & Documentation.
AS Level ICT Data entry: Creating validation checks.
Pay Example (PFirst98) Please use speaker notes for additional information!
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
Controlling Program Flow with Looping Structures
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Visual Basic.net Functions. Function (Defined) A procedure that returns a value when called.
© by Pearson Education, Inc. All Rights Reserved.-Edited By Maysoon Al-Duwais 2.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
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,
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
ME 142 Engineering Computation I Interacting with Spreadsheets.
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
Custom Dialog Box Alternatives And Dealing with FileNames Joanna Wyrobek.
Visual Basic.NET Windows Programming
Data Validation and Protecting Workbook
CHAPTER FIVE Decision Structures.
Department Array in Visual Basic
Conditions and Ifs BIS1523 – Lecture 8.
Part A – Doing Your Own Input Validation with Simple VB Tools
Messages and Input boxes
Decisions and Conditions
Additional Topics in VB.NET
Introduction to Programming
Presentation transcript:

Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data as a result of ‘user error’ Checking to verify that appropriate values have been entered for a text box is called validation The validation may include checking the type of data, checking for specific values, or checking a range of values

Checking the Data Type: IsNumeric Function Used to make sure that the data entered is truly numeric The IsNumeric Function returns ‘True’ or ‘False’ to indicate the result of the value checked IsNumeric(Expression) The function tests whether the value is numeric and therefore can be used in a calculation, therefore helping to avoid problems in procedures that contain calculations

If the data cannot be converted to a number, the calculation cannot be performed and a Run-Time Error will occur, which can be prevented by checking the contents of a field after the data has been entered If IsNumeric(txtQuantity.Text) Then iQuantity = Val(txtQuantity.Text) lblDue.Caption = cPrice * iQuantity End If Checking for a Range of Values: Data Validation may also include checking the reasonableness of a value If Val(txtHours.Text) > 10 Then

Message Boxes If the value entered by a user is incorrect, then the user can be notified by displaying a Message Box A special type of VB Window in which a message can be displayed to a user Validating input data is an appropriate time to use a message box. If data is rejected, the user needs to be informed as to why the desired action was not achieved Msgbox “Message String”, [Buttons/Icons], “Caption of the Titlebar”

The Message String is the message that will appear in the message box The Buttons portion is optional; it determines the command buttons that will be displayed and any icons that will appear If The Caption of Title Bar is omitted, then the project name will appear in the message box title bar Message Boxes can be used as a statement, which displays an ‘OK’ button only, or it can be used a s a function The Message Box Function returns a value indicating which button was pressed

Display a message box in the Else clause of an If statement when checking the validity of data If IsNumeric(txtQuantity.Text) Then iQuantity = Val(txtQuantity.Text) lblDue.Caption = cPrice * iQuantity Else MsgBox “Please enter a numeric value”, vbOKonly, “Error” End If

Message Box (Function) Msgbox “Message String”, [Buttons/Icons], “Caption of the Titlebar” Function Return Values The MsgBox Function returns a value that can be tested in a condition using a value (numbers 1 through 7) or an associated intrinsic constant Button Specification and/or Icons to Display The user can specify which buttons to display by using numbers or the VB intrinsic constants, to choose the buttons and an icon, use a plus sign to add the 2 values together

The Message Box Function (Example) Dim iResponse As Integer iResponse = MsgBox(“Do you wish to continue?”, vbYesNo + vbQuestion, “Continue Processing …..”) If iResponse = vbYes Then Text1.Text = InputBox(“Please enter a value”, “Enter a Value”) Else Text1.Text = “ ” End If

Set to Default

No Default

No Option Selected