Click to See Complete Forum and Search --> : finding numbers in an input file


JCasey
April 8th, 2001, 08:09 AM
I have two problems I have been working on since 10am Sat. The first is an input file problem where you have to find the highest and lowest bid using an if statement. I can get the highest bid by using If bids > highestbid then highestbid =bid and feel the next part should be an ElseIf but can't get the lowest to come up.

This one looking for input from user, name age and current salar and determine how much money they will make by age 65. I don't even know if I'm on the right track. As it goes through the for yrs 1 to 65 doesn't it have to save each result somewhere to calculate totalEarnings. I'm so confused and teacher hasn't responded to email. Please help.
Private Sub CmdCalculate_Click()
' input employee name, age and current salary
' cmdCalculate will calculate salary at the age of
' 65 given a 5% increase each year.
Dim name As String, age As Single, salary As Single
Dim yrs As Single, rate As Single, wageIncrease As Single
Dim IncreasedSalary As Single, Increase As Single, totalSalary As Single

name = txtName.Text 'name of employee
age = Val(TxtAge.Text) 'current age of employee
salary = Val(txtSalary.Text) 'current salary of employee
yrs = 0 'difference from age to 65
rate = 0.05 'yearly salary increase
wageIncrease = 0 '5% increase * salary
IncreasedSalary = 0 'WageIncrease + salary


picDisplay.Cls
wageIncrease = rate * salary + salary
yrs = 65 - age
Increase = wageIncrease * rate
IncreasedSalary = wageIncrease
For yrs = 1 To 65
IncreasedSalary = wageIncrease * rate + IncreasedSalary

totalSalary = IncreasedSalary
Next yrs

picDisplay.Print name; " "; "will earn about"; FormatCurrency(totalSalary, 0)







End Sub

coolbiz
April 8th, 2001, 11:35 AM
Hmm .. well try the code below, I've not actually typed them in VB so have a go with it:


private Sub CmdCalculate_Click()
' input employee name, age and current salary
' cmdCalculate will calculate salary at the age of
' 65 given a 5% increase each year.
Dim name as string, age as Single, salary as Single
Dim yrs as Single, rate as Single, wageIncrease as Single
Dim IncreasedSalary as Single, Increase as Single, totalSalary as Single

name = txtName.Text 'name of employee
age = Val(TxtAge.Text) 'current age of employee
salary = Val(txtSalary.Text) 'current salary of employee

' Cool Bizs: first determine if the age is >= 65
if (age >= 65) then
msgbox "Sorry! Can Continue!"
exit sub
endif

' Cool Bizs: init some vars
picDisplay.Cls
totalSalary = 0
IncreasedSalary = salary ' current salary

' start calculating from next year
for yrs = (age+1) to 65
' Cool Bizs: this year salary is 105% of last year salary
IncreasedSalary = (105 * IncreasedSalary)

' total salary from the beginning
totalSalary = totalSalary + IncreasedSalary
next yrs

' Cool Bizs: I think you want to display IncreasedSalary instead of totalSalary
' display result
picDisplay.print name; " "; "will earn about"; FormatCurrency(totalSalary, 0)
end sub




Email me if you still having problem:
-Cool Bizs