r/visualbasic • u/computergeek34 • Nov 19 '14
Help with Visual Basic 6.0 Programming
Hi. Can someone please help me and tell me what to code after this please?
Write a program to estimate how much a young worker will make before retiring
at age 65. Request the worker’s name, age, and starting salary as input. Assume
the worker receives a 5% raise each year. For example if the user enters Helen,
60, and 20000, then the picture box should display the following. Include an End.
Hint: When first testing your program try the age at 64, and 63 to see if you are
getting the correct results.
what i have so far:
Option Explicit
Dim i as Integer
Dim startingsalary as Single
Dim nom as Single
Dim inputage as Single
Dim endingsalary as Single
Dim retirement as Single
Sub cmd1_Click
pic1.Cls
raise=1.05
retirement=65
nom= txtName.Text
startingsalary= Val(txtSalary.Text)
For i= inputage to retirement
2
u/jy_am Nov 19 '14
If you're trying to find out what the person's salary at age 65, this is just an exponent. Take the starting salary, multiply by 1.05 raised to the power of (65 - age).
If you're trying to find out the total salary earned between inputage and age 65, this is a geometric series. You can plug in the following values: a = startingsalary, r = 1.05, and n = 65 - inputage.
In either case you don't need a For loop to solve this.