problem create a windows-based application that will calculate the gross pay earned for a worker,...

14

Upload: monica-davis

Post on 12-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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
Page 2: 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

ProblemCreate a Windows-based application that will

calculate the Gross Pay earned for a worker, given the number of hours worked and hourly pay rate.

Page 3: 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

Problem SolvingInput (controls):

Hours WorkedHourly Pay Rate

Process (event handling):Calculate Gross Pay

Gross Pay = hoursWorked * hourlyPayRate

Output (controls):Gross Pay

Page 4: 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

Creating the Visual Basic ApplicationEvent Driven Programming

Create the Interface / Window first Input Output

Then Code the Application Process Event Handing Methods

Page 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

Creating the InterfaceInput

Hours Worked Textbox, LabelHourly Pay Rate Textbox, Label

OutputGross Pay Earned Label (title), Label

(display info)Events

Calculate Gross Pay ButtonExit Program Button

Page 6: 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

Design the Interface – TOE ChartTask (T) Object (O) Event (E)

Input Hours Worked Textbox, Label None

Input Pay Rate Textbox, Label None

Output Gross Pay Label (display), Label (title)

None

Calculate Gross Pay Button Click

Exit Program Button Click

Page 7: 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

Create Your Interface

LabelLabelLabel

Text Box Text Box

Label

2 Buttons

Page 8: 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

PropertiesForm1

Name = frmWageCalculatorText = “Wage Calculator”

Label1No Need to Rename (Display Only – will not use)Text = “Number of Hours Worked”

Label2No Need to Rename (Display Only)Text = “Hourly Pay Rate”

Label3No Need to Rename (Display Only)Text = “Gross Pay Earned”

Page 9: 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

Properties Textbox1

Name: txtHoursWorked Text: <blank>

Textbox2 Name: txtPayRate Text: <blank>

Label4 Name: lblGrossPay (needs name because will will use this label) Text: <blank> Autosize: Off BorderStyle: FixedSingle

Button1 Name: btnCalculate Text: “&Calculate Gross Pay”

Button2 Name: btnExit Text: “E&xit”

Page 10: 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

Process – Event HandlingbtnCalculate

Button Click Event

Assignment statement Gets the data from the text field of the txtHoursWorked

textbox and the txtPayRate textbox. Assign the calculation data from the textboxes into the

lblGrossPay text fieldVal changes the text input from the text box into a

number

Page 11: 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

Event HandlingbtnExit

Button Click EventEnd

Page 12: 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

Run & Test ProgramSyntax Errors – Language Errors

Caught by the Compiler & InterpreterVisual Basic – wavy line under problem code

Run-Time ErrorsCauses Program to Crash

Logic ErrorsProgram Runs but gets “Wrong Answer”

Page 13: 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

Run & Test ProgramMust test for expected and unexpected input

Page 14: 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

HomeworkCreate a “Multiplication Tables” application.

The program should allow the user to input 2 numbers and then display the product of those 2 numbers. (Remember to use the val function)