Visual basik

Do Until intNumberOfEntries > MaxNumberOfEntries

decTotalMortgage = decDownPayments * (1 + decInterest)

lstTotalPerYear.Items.Add(decTotalMortgage)

decTotalMortgage += decDownPayments

intNumberOfEntries = intNumberOfEntries + 1


Loop


im at the point where it loops the same number for the first year but i want it to add up each year. someone said to Add a second loop that loops through your years.

i dunno how to do that, pleas help

Attached: code version 4.0.png (774x789, 72K)

Other urls found in this thread:

en.wikipedia.org/wiki/Dim_sum
twitter.com/AnonBabble

post your code here, no screenshot
use [ code ] tag (remove space)

the problem is that ur using visual basic instead of a good language

strDownPayments = InputBox(strSavingsInputMessage & strInputHeading, " ")
lblSavings.Text = " $" & strDownPayments ' we needed to finish this line, also the $ puts the $ sign in front of the label when the input feeds the label
decDownPayments.ToString("C")

strInterest = InputBox(strInterestInputMessage & strInputHeading, " ")
lblInterest.Text = " " & strInterest & " %" ' same stuff here i added the percent sign to what the display will look like
decInterest.ToString("P")

strYears = InputBox(strYearInputMessage & strInputHeading, " ")
lblYears.Text = " " & strYears & " Years" ' added the year line after the program shows how many years we working with
intYears.ToString("N")


'****************
decDownPayments = CInt(Convert.ToDecimal(strDownPayments))
decInterest = Convert.ToDecimal(strInterest)
intYears = CInt(Convert.ToDecimal(strYears))
'****************


Dim MaxNumberOfEntries As Integer = intYears
Dim intNumberOfEntries As Integer = 1


Do Until intNumberOfEntries > MaxNumberOfEntries

decTotalMortgage = decDownPayments * (1 + decInterest)

lstTotalPerYear.Items.Add(decTotalMortgage)

decTotalMortgage += decDownPayments

intNumberOfEntries = intNumberOfEntries + 1


Loop

now post some input sample, values that you entered. then tell us what is your expected output.

thx for taking the time to help me:

i would like the total in the listbox to add up every year from the previous year .

picture is included to see what its doing now

Attached: example.png (465x376, 153K)

what's your expected output? give real examples in numbers.

my expected output would look like

year one is 320 and year 2 is the first year 320 added to another 320 for year two. and year three is the sum of year one and two with another 320 added and so on until 5 years have gone by.

year 1 = 320
year 2 = 640
year 3 = 960
etc?

Kek at visual basic. Learn a nice language

yo
are you still here
need to go for a while
be back in 2 hours

yes, exacly that. until the amount of year entered.

Bump, please halp

isn't visual basic ded?

Maybe he wants to automate Excel and shiet.

It is, but some firms still use it because legacy shit.

brb creating a GUI in visual basic to hack ur IP

Plz, no bully. ;_;

Are you back?

he's not a killer, you can't track his IP
in certain country, VB is still popular. like in my country. VB.Net is more popular than C#
yeah, just arrived. give me several minutes

okay, since i hate gui (not gonna make one for tracking a killer's ip), i use console app

your code has some problems
first, these 3 statements do nothing:
decDownPayments.ToString("C")
decInterest.ToString("P")
intYears.ToString("N")


Look at my code to format the string using the numerical values in next post.

Module Module1

Sub Main()

Dim strDownPayments As String
Dim decDownPayments As Decimal

Dim strInterest As String
Dim decInterest As Decimal

Dim strYears As String
Dim intYears As Integer

Dim decTotalMortgage As Decimal
Dim lstTotalPerYear As List(Of Decimal) = New List(Of Decimal)

strDownPayments = "100"
decDownPayments = Convert.ToDecimal(strDownPayments)
strDownPayments = decDownPayments.ToString("C")

strInterest = "2.2"
decInterest = Convert.ToDecimal(strInterest)
strInterest = decInterest.ToString("P")


strYears = "5"
intYears = Convert.ToInt32(strYears)
strYears = intYears.ToString("N")

Dim MaxNumberOfEntries As Integer = intYears
Dim IntNumberOfEntries As Integer = 1

Do Until IntNumberOfEntries > MaxNumberOfEntries

'problem is here, decTotalMortgage should be accumulated, but you replaced it with new value in each iteration
decTotalMortgage += decDownPayments * (1 + decInterest)

lstTotalPerYear.Add(decTotalMortgage)

'decTotalMortgage += decDownPayments

IntNumberOfEntries = IntNumberOfEntries + 1

Loop

Console.WriteLine("Down payment = {0}", strDownPayments)
Console.WriteLine("Interest = {0}", strInterest)
Console.WriteLine("Years = {0}", strYears)

For i = 0 To lstTotalPerYear.Count - 1
Console.WriteLine("Mortgage {0} = {1}", i + 1, lstTotalPerYear(i))
Next

Console.WriteLine("Press any key...")
Console.ReadKey(True)

End Sub

End Module

Result is:
Down payment = $100.00
Interest = 220.00 %
Years = 5.00
Mortgage 1 = 320.0
Mortgage 2 = 640.0
Mortgage 3 = 960.0
Mortgage 4 = 1280.0
Mortgage 5 = 1600.0
Press any key...

Dim Dick As Double;

Delete lines 79 to 81, you don't need them.

Dim Sum = "Delicious"

en.wikipedia.org/wiki/Dim_sum

notice semicolon at the end of line
won't compile, basic is not c-style language

where are you?

hey i wanted for any number to be calculated by the number of years. here it look slike your starting with 320. i wanted it to be any number of mortgage

i hardcoded the values (down payment, interest, years) because i just want to demonstrate how to do the calculation correctly. you should get those values from inputs.

try changing the values in my code to see different results. but like i said, in your code, you must get those values from inputs.

I have the inputbox that send them to the labels

so problem is solved?

I don't see the year accumulation part

see this these are the result you wanted right?

i made small changes in 2 lines:
first:
decTotalMortgage = decDownPayments * (1 + decInterest)
becomes
decTotalMortgage += decDownPayments * (1 + decInterest)

then remark this line, not needed
'decTotalMortgage += decDownPayments

So updated to this
decTotalMortgage += decDownPayments * (1 + decInterest)

That's it?

don't forget to remove this line below, it will mess up the calculation because it's already accumulated
decTotalMortgage += decDownPayments

It works!!! So clutch my presentation is in 2 minutes. Good job to all.

good luck user
and learn how to debug, it's the key to find bugs in code

strDownPayments = InputBox(strSavingsInputMessage & strInputHeading, " ")
lblSavings.Text = " $" & strDownPayments ' we needed to finish this line, also the $ puts the $ sign in front of the label when the input feeds the label
decDownPayments.ToString("C")

strInterest = InputBox(strInterestInputMessage & strInputHeading, " ")
lblInterest.Text = " " & strInterest & " %" ' same stuff here i added the percent sign to what the display will look like
decInterest.ToString("P")

strYears = InputBox(strYearInputMessage & strInputHeading, " ")
lblYears.Text = " " & strYears & " Years" ' added the year line after the program shows how many years we working with
intYears.ToString("N")


'****************
decDownPayments = CInt(Convert.ToDecimal(strDownPayments))
decInterest = Convert.ToDecimal(strInterest)
intYears = CInt(Convert.ToDecimal(strYears))
'****************


Dim MaxNumberOfEntries As Integer = intYears
Dim intNumberOfEntries As Integer = 1

MAINLOOP:

Do Until intNumberOfEntries > MaxNumberOfEntries

decTotalMortgage = decDownPayments * (1 + decInterest)

lstTotalPerYear.Items.Add(decTotalMortgage)

decTotalMortgage += decDownPayments

intNumberOfEntries = intNumberOfEntries + 1

Loop


If checkyearetc then
intYears = intYears + 1
GOTO MAINLOOP
end if

Then he would just use python~

>GOTO
dafuq?

Looks like the formula is wrong, the percent interest is giving the wrong total mortgage.

Teacher is here but waving started yet

are you OP?

Yea, looks like it starts the list from after 5 years and not from year 1 to year 5

what do you mean? didn't you say it works?

Got a b minus for the project
A minus for the class.

Thx all.

good for you
continue polishing your programming skill