Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,444 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,219 people online right now. Registration is fast and FREE... Join Now!




ControlChar.Tab problem

 
Reply to this topicStart new topic

ControlChar.Tab problem

maggiec
17 Nov, 2007 - 10:19 PM
Post #1

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 5


My Contributions
CODE
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
        'Exit the project.

        Me.Close()
    End Sub

    Private Sub BtnCalculatePayments_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalculatePayments.Click
        'Declaring the variables
        Dim intInterestRateAmt As Decimal
        Dim intLoanAmt As Decimal
        Dim intLoanPeriodAmt As Decimal
        Dim strOutput As Decimal
        Dim decTotalPaid As Decimal
        Dim decMonthlyPayment As Decimal
        Dim dblInterestRateAmt As Decimal
        Dim dblPrincipal As Decimal
        Dim intNumberOfPayments As Integer
        Dim dblEndingInterestRateAmt As Decimal
        Dim dblStartingInterestRateAmt As Decimal
        Dim dblEndingInterestRate As Decimal
        Dim dblStartingInterestRate As Decimal
        Dim dblInterestRate As Decimal


        strOutput = "Number of Payments" & ControlChars.Tab & ControlChars.Tab & "Interest Rate" & ControlChars.Tab & "Monthly Payments" & _
        ControlChars.Tab & " Total Paid"
        strOutput &= ControlChars.NewLine & "Number of Payments" & ControlChars.Tab & "Interest Rate" & _
        ControlChars.Tab & ControlChars.Tab & "Monthly Payment" & ControlChars.Tab & "Total Paid"

        dblPrincipal = Val(Me.TxtLoanAmt.Text)
        dblInterestRate = Val(Me.TxtInterestRateAmt.Text)
        dblStartingInterestRate = dblInterestRateAmt - 0.05
        dblEndingInterestRate = dblInterestRateAmt + 1
        intNumberOfPayments = Val(Me.TxtLoanPeriodAmt.Text)


        For dblInterestRateAmt = dblStartingInterestRate To dblEndingInterestRate Step 0.05

            decMonthlyPayment = Pmt(dblInterestRateAmt / 100 / 12.0, intNumberOfPayments, -dblPrincipal)

            decTotalPaid += decMonthlyPayment
        strOutput &= ControlChars.NewLine & String.Format("{0:D}", intNumberOfPayments) & ControlChars.Tab _
        & ControlChars.Tab & String.Format("{0:F2}", dblInterestRate) & ControlChars.Tab _
        & ControlChars.Tab & String.Format("{0:C2}", decMonthlyPayment) &
        ControlChars.Tab _
        & String.Format(" {0:C2}", decTotalPaid)
        Next

        Me.TxtResults.Text = strOutput

    End Sub

    Private Sub TxtResults_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtResults.TextChanged

    End Sub

End Class


The errors that I am receiving are:
Error 1 Expression Expected (This is for the & after"decMonthlyPayment)
Error 2 Expression is not a method. This is for the ControlChars.Tab in the next to the last line.
Error 3 Expression Expected. This is for the & sign in the line before "Next"
Error 4 Method must be enclosed in parenthesis. This is showing the as being the same & sign as the error before.

I'm not sure why I got these errors, or even how to fix them. These are to display results in a table from calculations made for payment information. Any suggestions would be greatly appreciated.

This post has been edited by jayman9: 17 Nov, 2007 - 11:47 PM
User is offlineProfile CardPM
+Quote Post

Jayman
RE: ControlChar.Tab Problem
17 Nov, 2007 - 11:50 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,300



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Moving to VB.NET
User is online!Profile CardPM
+Quote Post

aceofspades686
RE: ControlChar.Tab Problem
18 Nov, 2007 - 03:03 AM
Post #3

D.I.C Regular
Group Icon

Joined: 8 Oct, 2007
Posts: 261


Dream Kudos: 100
My Contributions
First glance, its because you're lacking the underscore that lets you line break while still working on the same "line" in VB.NET. There should be one after decMonthlyPayment) &. Try this out and I'll be able to take a closer look a little later (or someone else could beat me to it).
User is offlineProfile CardPM
+Quote Post

maggiec
RE: ControlChar.Tab Problem
18 Nov, 2007 - 04:11 AM
Post #4

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 5


My Contributions
QUOTE(aceofspades686 @ 18 Nov, 2007 - 04:03 AM) *

First glance, its because you're lacking the underscore that lets you line break while still working on the same "line" in VB.NET. There should be one after decMonthlyPayment) &. Try this out and I'll be able to take a closer look a little later (or someone else could beat me to it).




QUOTE(maggiec @ 18 Nov, 2007 - 05:06 AM) *

QUOTE(aceofspades686 @ 18 Nov, 2007 - 04:03 AM) *

First glance, its because you're lacking the underscore that lets you line break while still working on the same "line" in VB.NET. There should be one after decMonthlyPayment) &. Try this out and I'll be able to take a closer look a little later (or someone else could beat me to it).



I tried this and this did not do anything. The errors are still there.
This is what the program is supposed to do:

calculate loan payments based on amount borrowed, loan period and interest rate. Your program will employ a loop to repeat the calculation for different interest rates and a decision structure to display a message if the payback amount is more than double the amount of the original loan. Accept the input from the user and subtract 0.5 from the interest rate. You will then calculate payments starting with your calculated interest rate and increasing in quarter point increments (0.25) up to one full percentage point above that input by the user.



I tried this and this did not do anything. The errors are still there.
This is what the program is supposed to do:

calculate loan payments based on amount borrowed, loan period and interest rate. Your program will employ a loop to repeat the calculation for different interest rates and a decision structure to display a message if the payback amount is more than double the amount of the original loan. Accept the input from the user and subtract 0.5 from the interest rate. You will then calculate payments starting with your calculated interest rate and increasing in quarter point increments (0.25) up to one full percentage point above that input by the user.
[/quote]

This post has been edited by maggiec: 18 Nov, 2007 - 04:08 AM
User is offlineProfile CardPM
+Quote Post

maggiec
RE: ControlChar.Tab Problem
18 Nov, 2007 - 04:54 AM
Post #5

New D.I.C Head
*

Joined: 17 Nov, 2007
Posts: 5


My Contributions
Ok, I got rid of the errors. I just adjusted the underscore a little and the errors went away. Now when I debug, I am getting another error. This is where the error is:

strOutput = "Payments" & ControlChars.Tab & ControlChars.Tab & "Interest" & ControlChars.Tab & "Monthly" & _
ControlChars.Tab & " Total"

A box pops up and says:


Conversion from string "Payments Interest Monthly Tota" to type 'Decimal' is not valid.

What does this mean and how can I fix it?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 12:44PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month