January 5th, 2006

Payroll Program

First design it, as follow

 

Then double click on the form and program it.

 

'declaration: first declare all the variables'

Dim employeeid As Integer

Dim hoursworked As Double

Dim hourlyrate As Double

Dim grosspay As Double

Dim taxamount As Double

Dim netpay As Double

'second part: inputs'

hoursworked = TextBox2.Text

hourlyrate = TextBox3.Text

'computation'

grosspay = hoursworked * hourlyrate

taxamount = grosspay * 0.1

netpay = grosspay - taxamount

'output'

TextBox5.Text = FormatCurrency(taxamount)

TextBox4.Text = FormatCurrency(grosspay)

TextBox6.Text = FormatCurrency(netpay)

 

 

 

Here is how to do combo box?

'declaration: first declare all the variables'

Dim employeeid As Integer

Dim hoursworked As Double

Dim hourlyrate As Double

Dim grosspay As Double

Dim taxamount As Double

Dim netpay As Double

Dim taxrate As Double

'second part: inputs'

hoursworked = TextBox2.Text

hourlyrate = TextBox3.Text

taxrate = ComboBox1.Text

'computation'

grosspay = hoursworked * hourlyrate

taxamount = grosspay * taxrate

netpay = grosspay - taxamount

'output'

TextBox5.Text = FormatCurrency(taxamount)

TextBox4.Text = FormatCurrency(grosspay)

TextBox6.Text = FormatCurrency(netpay)

 

make sure you insert the taxrate in the combo box

 

Dr. Ebrahimi

The word interactively means give and take

Assignmet 1 was basically spicification

What was the requirement building up the payroll program?

Assignment 2A was to compute the Gross Pay, providing hours worked, hourly rate and ID

Assignment 2B was to compute the Net Pay, providing tax amount and gross pay (20%)fixed tax rate in book 10%

We asked the user to enter input, we process, we respond back to user which is output

 

WE WILL BE DOING LOOP, Loop means repeat

One way to repeat to execute a program, but we don't want to do execute program everytime.

Assignment 3A is loop to 2B for 5 times. Because we have five employees for that reason we will be repeating 5 times

Assignment 3B is will repeat 5 times but the data will come from input files (we do not enter data)

loop and files and if statement, you make a search engine

One loop>>>>if statement>> data comes>>search engine

3C says repeat as many employees you have

if you want to run for 500 times just change the number to 500 instead of 5. It will then loop 500 times

Page 53: Loop as a labor force

Loop as a mewl (donkey), it does all the carry you will need. its has ability to repeat over and over and don't get tired.
just add a line above and one on bottom will loop your program.

Can you think of loop? of course.. sleep, drinking, eating etc...

READ EVERY CHAPTER CAREFULLY, IT IS DESIGNED TO

You wouldn't have to worry how many items you have in the supermarket or how many employees you have.

In order to do search you have to have loop in it.

Search goes until what you need

Program on page 62

INVOICE PROGRAM

Dim itemid, quantity, unitprice, subtotal, counter As Integer

Dim totalprice As Double

Const taxrate As Single = 0.08

Dim taxamount As Single

counter = 5

While counter > 0

itemid = InputBox("Please Enter the Item ID")

quantity = InputBox("Please Enter the Quantity")

unitprice = InputBox("Please Enter the Unitprice")

subtotal = quantity * unitprice

taxamount = subtotal * taxrate

totalprice = subtotal + taxamount

MsgBox("The Item's Id is " & itemid)

MsgBox("The Quantity is " & quantity)

MsgBox("The Subtotal is " & subtotal)

MsgBox("The Tax Amount is " & taxamount)

MsgBox("The Total Price is " & totalprice)

counter = counter - 1

End While

zero (0) is always false and anything besides 0  is true. Zero it will stop.

if you run this program with 0 it wouldn't run and if you run this program other number besides 0 it would loop for forever & infinite.

 

 

 

 

 

'when items have the same data type you can combine into one statement for example dim itemid, quantity,  unitprice as integer'