Problem that i still dont know.

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1702 Views - Last Post: 20 March 2013 - 09:55 AM Rate Topic: -----

#16 egeboy099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 18-September 12

Re: Problem that i still dont know.

Posted 20 March 2013 - 08:53 AM

View PostCharlieMay, on 20 March 2013 - 08:24 AM, said:

I'm afraid that without me actually just fixing the code you supplied in your first post, that it's doesn't get much easier than what I just explained.

Have you even tried putting that information into your Schedule Button?

Here's a tip, don't copy and paste it, type it in there and when you get to the second line to the point of typing ASchedule. you should have an eye-opening experience as to what you need to do.

If that's not enough, then I suggest you go to the VB.Net FAQ & Resources topic that AdamSpeight2008 has pinned to the top of the forum and work through the first entry "Just Started VB.Net? Stuck?" because it appears there's a lot of the basics that you're not understanding yet.



i already figure it out.

i remove the class
so there will be only a single class.

heres the code :

Public Class Form1

    Private Sub InterestPayment()

        Dim intAmount As Double = 0
        Dim principal As Double = Me.txtPrincipal.Text
        Dim intInterestRate As Double = Me.txtInterest.Text
        Dim principalPayment As Double = 0

        intAmount = (principal * intInterestRate * 0.01) / 12
        principalPayment = principal / CDbl(Me.txtPeriod.Text)
        txtMonthlyInterestPayment.Text = FormatCurrency(intAmount, 2)

        Me.txtMonthlyPrincipalPayment.Text = principalPayment

        Dim intPay As Double = CDbl(Me.txtMonthlyInterestPayment.Text)
        Dim principalpay As Double = Me.txtMonthlyPrincipalPayment.Text
        Dim TotalPayment As Double = intPay + principalpay

        Me.txtTotalPayment.Text = FormatCurrency(TotalPayment, 2)

    End Sub


    Private Sub btnCalculation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculation.Click

        If Not IsNumeric(Me.txtPrincipal.Text) Then
            MsgBox("Invalid principal value.", MsgBoxStyle.Exclamation, "Invalid Value")
            Return
        End If

        If Not IsNumeric(Me.txtPeriod.Text) Then
            MsgBox("Invalid period value.", MsgBoxStyle.Exclamation, "Invalid Period")
            Return
        End If

        If Not IsNumeric(Me.txtInterest.Text) Then
            MsgBox("Invalid interest rate value.", MsgBoxStyle.Exclamation, "Invalid Interest Rate")
            Return
        End If

        InterestPayment()

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

        Dim dPrincipal As Double = 0
        Dim dIntInterestRate As Double = 0
        Dim iPeriod As Integer
        Dim dtValueDate As Date
        Dim sType As String = ""

        Public WriteOnly Property Principal() As Double
            Set(ByVal value As Double)
                dPrincipal = value
            End Set
        End Property


        Public WriteOnly Property InterestRate() As Double
            Set(ByVal value As Double)
                dIntInterestRate = value
            End Set
        End Property


        Public WriteOnly Property Period() As Integer
            Set(ByVal value As Integer)
                iPeriod = value
            End Set
        End Property

        Public WriteOnly Property ValueDate() As Date
            Set(ByVal value As Date)
                dtValueDate = value
            End Set
        End Property


        Public WriteOnly Property LoanType() As String
            Set(ByVal value As String)
                sType = value
            End Set
        End Property

        Private Sub GenerateScheule()
            Dim monthlyInt As Double = 0
            Dim monthlyPrincipal As Double = 0
            Dim dtDate As Date
            Dim total As Double

            monthlyInt = (dPrincipal * dIntInterestRate * 0.01) / 12
            monthlyPrincipal = dPrincipal / iPeriod

            For i As Integer = 1 To iPeriod
                dtDate = dtValueDate.AddMonths(i)

                total = monthlyPrincipal + monthlyInt

            dgvLoanSchedule.Rows.Add(i, Format(dtDate, "dd/MMM/yyyy"), FormatCurrency(monthlyInt, 2), FormatCurrency(monthlyPrincipal, 2), FormatCurrency(total, 2))

                dPrincipal -= monthlyPrincipal
                monthlyPrincipal = dPrincipal / iPeriod
                monthlyInt = (dPrincipal * dIntInterestRate * 0.01) / 12

            Next
        End Sub

    Private Sub btnSchedule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSchedule.Click
        GenerateScheule()
    End Sub
End Class





no more error but still the schedule button dont generate the dates... still blank datagridview.
   Private Sub btnSchedule_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSchedule.Click
        GenerateScheule()
    End Sub


Was This Post Helpful? 0
  • +
  • -

#17 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Problem that i still dont know.

Posted 20 March 2013 - 09:13 AM

You're probably going to be very sad when I tell you that the class you just removed was what ran the amortization routine and populated that grid you're having issues with.

I guess your next step is to step through using the debugger and find out why it's not working for you.

This post has been edited by CharlieMay: 20 March 2013 - 09:16 AM

Was This Post Helpful? 0
  • +
  • -

#18 egeboy099  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 18-September 12

Re: Problem that i still dont know.

Posted 20 March 2013 - 09:18 AM

View PostCharlieMay, on 20 March 2013 - 09:13 AM, said:

You're probably going to be very sad when I tell you that the class you just removed was what ran the amortization routine and populated that grid you're having issues with.

I guess your next step is to step through using the debugger and find out why it's not working for you.


so what should i fix now?
Was This Post Helpful? 0
  • +
  • -

#19 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Problem that i still dont know.

Posted 20 March 2013 - 09:55 AM

I guess the only answer I have for you is to take that "Simple code" as you stated in your first post, back to it's original state and read through the topic again. The answer is there, it's not cryptic. I really feel at this point that you're just looking for someone to fix the code and repost it so you can run with it.

I will say that to get this code to work based on the example I gave you would only end up having about 5 lines of code in your schedule button's click even that would produce a result.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2