Validation "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to.

Slides:



Advertisements
Similar presentations
EasyGUI “Probably the Easiest GUI in the world”. Assumptions (Teachers’ Notes) This resources sets out an introduction to using easyGUI and Python
Advertisements

Driving Test 1 Marking Scheme Focus on five areas to pass driving test 1.
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
30/04/ Selection Nested If structures & Complex Multiple Conditions.
28/08/2015SJF L31 F21SF Software Engineering Foundations ASSUMPTIONS AND TESTING Monica Farrow EM G30 Material available on Vision.
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
PHP : Hypertext Preprocessor
Server-Side Validation Jayden Bryant. What is Server-Side Validation?  Validation of form input done on the server, not the web browser program //Validate.
Visual Basic: An Object Oriented Approach 5: Structured Programming.
1 DoD Cardholder Self Registration November 21, 2008.
MAIL MERGE Designing Documents with. Terms Mail Merge: A process that inserts variable information into a standardized document to produce a personalized.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Variables "There are 10 kinds of people in the world today – those who understand binary and those who don't!” Unknown.
07/10/ Strings ASCII& Processing Strings with the Functions - Locate (Instr), Mid, Length (Len), Char (ChrW) & ASCII (Asc)
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
19/10/20151 Data Structures Arrays. 219/10/2015 Learning Objectives Explain initialising arrays and reading data into arrays. Design and write routine/s.
CW-V1 SDD 0601 Principals of Software Design and Development Variables Constants Data Types Error Handling Starter: BlockbustersBlockbusters.
Creating a Database Designing Structure, Capturing and Presenting Data.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Systems Life Cycle. Know the elements of the system that are created Understand the need for thorough testing Be able to describe the different tests.
String Manipulation. Strings have their own properties and methods, just like a textbox or label or form does.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
{ Dating Service ActionHandler Listener class details.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
22/11/ Selection If selection construct.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Verification & Validation. Batch processing In a batch processing system, documents such as sales orders are collected into batches of typically 50 documents.
1 Project 3 The Kumquat Society Conference. 2 Conference Registration In this project you will write a program to handle a conference registration. The.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Validation final steps Stopping gaps being entered in an input.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
String Manipulation 10/21/2015 Lect#6 GC Strings have their own properties and methods, just like a textbox or label or form does. 10/21/2015 Lect#6.
31/01/ Selection If selection construct.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
110 F-1 Decisions and Conditions Chapter 4: We can design a form We can calculate To make our programs more powerful, we need to be able to make choices.
How to set up an account- Non-Technical Aimee Lilley.
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
Making Interactive Programs with Visual Basic .NET
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Objects Allow us to represent and control the computer technology Use methods to make the object do something Use properties to find out and change the.
String Manipulation Reference:
DATA TYPES.
A variable is a name for a value stored in memory.
Bonneville Junior High’s Locker Program
Handling Data Designing Structure, Capturing and Presenting Data
Variables Data Types and Assignment
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Department Array in Visual Basic
Conditions and Ifs BIS1523 – Lecture 8.
Use proper case (ie Caps for the beginnings of words)
String Manipulation Reference:
If selection construct
4.1 Strings ASCII & Processing Strings with the Functions
If selection construct
Text / Serial / Sequential Files
String Manipulation Reference:
Handling Data Designing Structure, Capturing and Presenting Data
Variables Data Types and Assignment
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Variables Data Types and Assignment
Text / Serial / Sequential Files
8 Records 25/07/2019.
Presentation transcript:

Validation "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.“ Rich Cook

Robust and Responsive Robust means that a user may type any data they like into the program and it won’t crash Responsive means that the program will tell the user what they have done wrong and what they should do to correct the error

What is wrong with the following? Dim FirstName as Integer FirstName=”Fred”

What is wrong with the following? Dim Age as Integer Age = txtAge.Text

IsNumeric ‘declare a variable to store the age Dim Age as Integer ‘test the data typed in the text box to see if it is a number If IsNumeric(txtAge.Text)=True Then ‘if it is ok read in the value Age = txtAge.Text Else ‘if not ok then show an error lblError.Text = "The age is not valid" End If

IsDate ‘declare a variable to store the date of birth Dim DOB as Date ‘test the data typed in the text box to see if it is a date If IsDate(txtDOB.Text)=True Then ‘if it is ok read in the value DOB = txtDOB.Text Else ‘if not ok then show an error lblError.Text = "The date of birth is not a valid date" End If

Testing for a blank field (=“”) ‘declare a variable to store first name Dim FirstName as String ‘test the data typed in the text box to see if it isn’t blank If txtFirstName.Text<>"" Then ‘if it is ok read in the value FirstName = txtFirstName.Text Else ‘if not ok then show an error lblError.Text = "You must enter your first name." End If

Testing Number of Characters (Len) ‘declare a variable to store first name Dim FirstName as String ‘test the data typed in the text box is not over 20 characters If Len(txtFirstName.Text)<=20 Then ‘if it is ok read in the value FirstName = txtFirstName.Text Else ‘if not ok then show an error lblError.Text = "First name must not exceed 20 letters." End If

Validating an Address (InStr) ‘declare a variable to store the address Dim as String ‘test the data typed in the text box has symbol If InStr(txt .Text, >0 Then ‘if it is ok read in the value = txt .Text Else ‘if not ok then show an error lblError.Text = "Not a valid address." End If Question – What is the problem with the above code?

The problem is… that the following are all valid addresses.. @

An Address Must Have… symbol “. ” symbol e.g. hotmail.com At least 5 characters (?)

(What is wrong with the following if we use ?) Dim as String ‘test the data typed in the text box has symbol If InStr(txt .Text, >0 Then = txt .Text Else lblError.Text = "Not a valid address." End If ‘test the address is long enough If Len(txt .Text) >5 Then = txt .Text Else lblError.Text = "The address is too short." End If ‘test the data typed in the text box has an. symbol If InStr(txt .Text, ".") >0 Then = txt .Text Else lblError.Text = "Not a valid address." End If

Better??? ‘declare a variable to store the address Dim as String ‘test the data typed in the text box has symbol If InStr(txt .Text, >0 Then ‘test the address is long enough If Len(txt .Text) >5 Then ‘test the data typed in the text box has an. symbol If InStr(txt .Text, ".") >0 Then ‘if it is ok read in the value = txt .Text Else lblError.Text = "Not a valid address." End If Else lblError.Text = "The address is too short." End If Else lblError.Text = "Not a valid address symbol." End If

Or…. ‘declare a variable to store the address Dim as String ‘clear the error message label lblError.Text = "" ‘test the data typed in the text box has symbol If InStr(txt .Text, = 0 Then lblError.Text = symbol." End If ‘test the address is long enough If Len(txt .Text) <=5 Then lblError.Text = lblError.Text & " The address is too short." End If ‘test the data typed in the text box has a. symbol If InStr(txt .Text, ".") = 0 Then lblError.Text = lblError.Text & "No dot." End If If lblError.Text = "" Then = txt .Text End IF

Validation in Action We shall look at the validation for the save button on “your details”

Questions 1. What is wrong with the following validation? Dim Age as Integer Age = txtAge.Text If IsNumeric(Age) = True Then If Age > 18 Then lblMessage.Text = “You are old enough” End If

Questions 2. Write code that validates if the text in txtName is less than 40 characters. If the length of the name is OK then a message should appear welcoming the person. 3. Write code that validates the text in txtPostCode to ensure that it is not blank. 4. Write code that validates the values in the fields, txtStartAge and txtEndAge also making sure that the start age is not greater than or equal to the end age.