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

Post on 12-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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.

Problem SolvingInput (controls):

Hours WorkedHourly Pay Rate

Process (event handling):Calculate Gross Pay

Gross Pay = hoursWorked * hourlyPayRate

Output (controls):Gross Pay

Creating the Visual Basic ApplicationEvent Driven Programming

Create the Interface / Window first Input Output

Then Code the Application Process Event Handing Methods

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

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

Create Your Interface

LabelLabelLabel

Text Box Text Box

Label

2 Buttons

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”

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”

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

Event HandlingbtnExit

Button Click EventEnd

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”

Run & Test ProgramMust test for expected and unexpected input

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)

top related