Lab 2 Due 9 pm, Friday, September 27 1. Put a “&” in button text The char after “&” is underlined and becomes the Access Key Example Text of btnExit:

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.
5.05 Apply Looping Structures
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
Welcome to CS 3260 Dennis A. Fairclough. Overview Course Canvas Web Site Course Materials Lab Assignments Homework Grading Exams Withdrawing from Class.
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.
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.
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.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
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”
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
Arrays Chapter 8. Chapter 8 - Part 12 Variable and Variable Array Variable Stores only one value Variable Array Variable that has 1 symbolic name but.
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.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Two Forms Please use speaker notes for additional information!
1 CS105 Discussion 5 – Variables and If Announcements MP 1 due on Monday Midterm 1 on Tuesday If you need a conflict, request it NOW!!
VAT Calculator program Controls Properties Code Results.
Pay Example (PFirst98) Please use speaker notes for additional information!
CS 2340: Programming in VB Lab 2 Due 9 pm, Friday, September 14 1.
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Tutorial 3: Using Variables and Constants1 Tutorial 3 Using Variables and Constants.
31/01/ Selection If selection construct.
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.
CS1010: Programming Methodology
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
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.
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
Department Array in Visual Basic
Use proper case (ie Caps for the beginnings of words)
CS 1430: Programming in C++ No time to cover HiC.
Windows Forms Introduction
Tonga Institute of Higher Education
Additional Topics in VB.NET
Presentation transcript:

Lab 2 Due 9 pm, Friday, September 27 1

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

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

 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

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

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

Method Show Overloaded Help Manage Help Settings View Help 7

MessageBoxIcon  Asterisk  Error  Exclamation  Hand  Information  None  Question  Stop  Warning 8

' 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

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

‘ 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

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

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

 Empty ID Error message  Spaces only Error message  String “CS 2340” Good ID  String “ CS 2340 ” Good ID 14

 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

 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

 Similar to testing rate  Negative number such as -1 Error message  Positive number Good Rate!  Number 0 Good Hours! Hours can be zero! 17

 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

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

 Friday, September 27  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