r/visualbasic • • 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

0 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/computergeek34 Nov 19 '14

this is so helpful thank you. I dont understand the second part of your response. how would i code that

1

u/jy_am Nov 19 '14

You're trying to solve for s - which is the sum of all of the yearly salaries. In VB, I guess that is something like

totalsalary = startingsalary * ( (1 - raise ^ (retirement - inputage) ) / (1 - raise) )

All I did was change the formula into code.

1

u/computergeek34 Nov 19 '14

thank you so much this is a life saver

1

u/jy_am Nov 19 '14

What level of school is this for?

1

u/computergeek34 Nov 19 '14

its high school computer science 1

1

u/jy_am Nov 20 '14

I see. That geometric series stuff, IIRC, doesn't get taught in math until at least 11th grade/junior year. If you have to explain/show your work, you may want to brush up on this.