CS 2340: Programming in VB Lab 2 Due 9 pm, Friday, September 14 1.

Slides:



Advertisements
Similar presentations
Chapter 1: An Introduction to Visual Basic 2012
Advertisements

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.
110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.
Instructor: Adil Ibrahim Office: 212 Ullrich Phone: ibrahima 1.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: YangQ 1.
CS 2340 Programming in VB.NET Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: YangQ 1.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
CS0004: Introduction to Programming Input and Output.
Chapter 4: The Selection Structure
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Problem Create a Windows-based application that will calculate the Gross Pay earned for a worker, given the number of hours worked and hourly pay rate.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
CSC 162 Visual Basic I Programming. Randomizing and Formatting Randomizing Formatting –User-Defined Formats –Named Numeric Formats.
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.
CIS 115 Lecture 4.  Create a Windows-based application that will calculate the Gross Pay earned for a worker, given the number of hours worked and hourly.
Chapter 4: The Selection Process in Visual Basic.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Clearly Visual Basic: Programming with Visual Basic 2008
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
1. S:\Courses\CSSE\ibrahima\CS2340\Notes Folder Section1 Folder Section2 2.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Visual Basic IITG to be expanded. What is Visual Basic? Object Oriented Programming Language (OOP) Graphical User Interface (GUI) Event Driven – Write.
Applications Development
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Illustration of a Visual Basic Program Running an Ada Program 1 by Richard Conn 11 September 1999.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
VAT Calculator program Controls Properties Code Results.
Lab 2 Due 9 pm, Friday, September Put a “&” in button text The char after “&” is underlined and becomes the Access Key Example Text of btnExit:
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
31/01/ Selection If selection construct.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
2c – Textboxes and Buttons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
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 FOUR Variables and Arithmetic Operations.
Using a Database Access97 Please use speaker notes for additional information!
Visual Basic.NET Programming for the Rest of Us Keith Mulbery Utah Valley State College.
CIS 338: Events Dr. Ralph D. Westfall April, 2011.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3 Variables and Calculations.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
Instructors: Sidra Ehsan Budoor Bawazeer CpCS 206.
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.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter One An Introduction to Visual Basic 2008.
Visual Basic Fundamental Concepts
Microsoft Visual Basic 2005: Reloaded Second Edition
A variable is a name for a value stored in memory.
Apply Procedures to Develop Message, Input, and Dialog Boxes
Chapter 1: An Introduction to Visual Basic 2015
Windows Desktop Applications
CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich
Variables and Arithmetic Operations
Visual Basic..
Department Array in Visual Basic
Windows Forms Introduction
Additional Topics in VB.NET
Presentation transcript:

CS 2340: Programming in VB Lab 2 Due 9 pm, Friday, September 14 1

Button Access Key (Hot Key) Put a “&” in button text The char after “&” is underlined and becomes the Access Key Example Text of btnExit: EXIT (E&XIT) [ALT] + X ==> the same as click btnExit 2

Form Properties Text (title) FormBorderStyle WindowsState: Normal, Minimized, Maximized StartPosition ControlBox: Control buttons Minimize, Maximize (restore), Close MinimizeBox, MaximizeBox 3

Form Properties Button Click Event Pressing ENTER when a button has the focus Multiple buttons on a form AcceptButton: Pressing ENTER when no button has the focus CancelButton Pressing ESC when no button has the focus Different ways to invoke the button click event 4

Invoking Event Procedures Private Sub btnExit_Click(...) Handles btnExit.Click End End Sub ' It will not work if Handles is removed. Private Sub btnExit_Click(...) End End Sub ‘ You could change the Sub’s name Private Sub SubExit(...) Handles btnExit.Click 5

Function Format and FormatCurrency txtSum.Text = Format(result, "Currency") txtSum.Text = Format(result, "C") txtSum.Text = Format(result, "General Number") txtSum.Text = Format(result, “n") txtSum.Text = Format(result, "Percent") txtSum.Text = Format(result, "P") txtSum.Text = Format(result, "Standard") txtGrossPay.Text = FormatCurrency(gross) 6

Message Box Method Show Overloaded Help Manage Help Settings View Help 7

Message Box MessageBoxIcon Asterisk Error Exclamation Hand Information None Question Stop Warning 8

String on Multiple Lines ' Special char vbCrLf MessageBox.Show("Invalid Hours!" + vbCrLf + _ "Hours must be non-negative!", _ "Lab 2", MessageBoxButtons.OK, MessageBoxIcon.Error) ' Special integer Keys.LineFeed ' Run time error MessageBox.Show("Invalid Hours!" + Keys.LineFeed + _ "Hours must be non-negative!", _ "Lab 2", MessageBoxButtons.OK, MessageBoxIcon.Error) ' Special integer Keys.LineFeed ' Cast function Chr MessageBox.Show("Invalid Hours!" + Chr(Keys.LineFeed) + _ "Hours must be non-negative!", _ "Lab 2", MessageBoxButtons.OK, MessageBoxIcon.Error) 9

GUI Programs Three Steps Input (from controls) Process (no controls) Output (to controls) 10

Click Event Procedure for btnCompute ‘ Declare variables Dim rate, hours, grossPay, deduction, netPay As Double Dim input As String ‘ Check ID input = txtID.Text.Trim()... ‘ Check Rate input = txtRate.Text.Trim()... ‘ Check Hours input = txtRate.Text.Trim()... ‘ Process ‘ No more controls! ' Display results using controls 11

Lab 2: Checking Rate input = txtRate.Text.Trim() If IsNumeric(input) And _ InStr(input, "e", CompareMethod.Text) = 0 Then rate = Convert.ToDouble(input) If rate <= 0 Then MessageBox.Show("Invalid Rate!" + vbCrLf & _ "Rate must be positive!", "Lab 2", _ MessageBoxButtons.OK, MessageBoxIcon.Warning) txtRate.Focus() Exit Sub End If Else MessageBox.Show("Invalid Rate!" + Chr(Keys.LineFeed) & _ "Rate must be a number!", "Lab 2", _ MessageBoxButtons.OK, MessageBoxIcon.Warning) txtRate.Focus() Exit Sub End If 12

Testing GUI Programs COURSE OUTCOMES... Design, develop and test Visual Basic programs. Users can enter whatever they want and in what order they like. We must make sure the program won’t crash and always work correctly! 13

Lab 2: Testing ID Empty ID Error message Spaces only Error message String “CS 2340” Good ID String “ CS 2340 ” Good ID 14

Positive and Negative Zero is a positive number. TrueFalse Zero is a negative number. TrueFalse Zero is a non-positive number. TrueFalse Zero is a non-negative number. TrueFalse 15

Lab 2: Testing Rate (positive) Empty rate Error message Not a number such as “cs2340” or 234cs Error message Scientific notation “2e3” Error message Scientific notation “2E-3” Error message Number 0 Error message Negative number such as -1 Error message Positive number Good Rate! 16

Lab 2: Testing Hours (non-negative) Similar to testing rate Negative number such as -1 Error message Positive number Good Rate! Number 0 Good Hours! Hours can be zero! 17

Lab 2: Testing Gross Pay Rate: 10 Hours 20 Gross Pay: 200 Rate: 10 Hours 40 Gross Pay: 400 Rate: 10 Hours 50 Gross Pay: 500? Gross Pay: 550? 18

Schedule Lab 2: Due 9pm, Friday, September 14 No Grace Time! Test 1: Friday, September 21 Based on Lab1 and Lab2 19

Test 1 Friday, September 21 Lab 206 Create a VB.NET program within 52 minutes 20 points Open book and notes Online help available Your labs available Do it yourself No No discussion No credit if no executable file or it does not run You can ask me for help, but you may lose 3 points each time you receive help You cannot ask me any questions during the last 15 minutes of the test! -3 for each run time error 20