txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Note that the DO LOOP continues until wrkToDate > Then the amount you have earned is shown in the text box. Every 7 years the amount in wrkToDate is displayed in the box. This is done using Mod 7. When the answer is evenly divisible by 7 then the information is printed."> txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Note that the DO LOOP continues until wrkToDate > Then the amount you have earned is shown in the text box. Every 7 years the amount in wrkToDate is displayed in the box. This is done using Mod 7. When the answer is evenly divisible by 7 then the information is printed.">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Do Loop with Interest Please see speaker notes for additional information!

Similar presentations


Presentation on theme: "Do Loop with Interest Please see speaker notes for additional information!"— Presentation transcript:

1 Do Loop with Interest Please see speaker notes for additional information!

2 Interest

3 Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, "@@@@"); Tab(6); Format(wrkPrintToDate, "@@@@@@@@@@@") End If Loop Until wrkToDate > 10000 txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Note that the DO LOOP continues until wrkToDate > 10000. Then the amount you have earned is shown in the text box. Every 7 years the amount in wrkToDate is displayed in the box. This is done using Mod 7. When the answer is evenly divisible by 7 then the information is printed.

4 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, ” $##,##0.00") picYrAmt.Print Format(wrkYr, "@@@@"); Tab(6); Format(wrkPrintToDate, "@@@@@@@@@@@") End If Interest This example uses formatting with the format function: Format(expression,str) where expression is the thing to be formatted using the rules that appear in str). There are predefined format such as “Currency” which display in leading dollar format, ”, “Percent” which displays with a percent sign and the data multiplied by 100, and “General Number” which displays as is etc. You can also use symbols such as the # which simple shows a space for a digit, 0 which means that the 0 should print, $ which will show etc. The @ means to define a string field with this many characters and fill with spaces if there are not enough. txtDeposit.Text = Format(txtDeposit.Text, "Currency")

5 Interest The textbox where the amount of money is displayed takes multiple lines. Note that MultiLine must be set to True.

6 Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do While wrkToDate < 10000 wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, "@@@@"); Tab(6); Format(wrkPrintToDate, "@@@@@@@@@@@") End If Loop txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdClear_Click() picYrAmt.Cls txtDepositor.Text = "" txtDeposit.Text = "" txtInt.Text = "" txtAnswer.Text = "" End Sub Private Sub cmdExit_Click() End End Sub Interest2

7 Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do While wrkToDate < 10000 wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, "@@@@"); Tab(6); Format(wrkPrintToDate, "@@@@@@@@@@@") End If Loop txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub Private Sub cmdCalculate_Click() Dim wrkInt As Single, wrkYr As Integer, wrkDeposit As Single, wrkToDate As Single wrkInt = Val(txtInt.Text) wrkYr = 0 wrkDeposit = Val(txtDeposit.Text) wrkToDate = wrkDeposit txtDeposit.Text = Format(txtDeposit.Text, "Currency") Do wrkToDate = wrkToDate * wrkInt + wrkToDate wrkYr = wrkYr + 1 If wrkYr Mod 7 = 0 Then wrkPrintToDate = Format(wrkToDate, "$##,##0.00") picYrAmt.Print Format(wrkYr, "@@@@"); Tab(6); Format(wrkPrintToDate, "@@@@@@@@@@@") End If Loop Until wrkToDate > 10000 txtAnswer.Text = "In " & wrkYr & " years, you earned " & Format(wrkToDate, "Currency") End Sub


Download ppt "Do Loop with Interest Please see speaker notes for additional information!"

Similar presentations


Ads by Google