Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Divide value again
Message
From
25/07/2006 02:42:48
 
 
To
24/07/2006 18:55:35
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01139252
Message ID:
01139581
Views:
11
hi,
i understand.... This is my final reply to it?

thank you for every thing,

compute no errors for all months if i start at first day or any day at month,
ex..
the value=800
if i start as 03/01/2006 or months 5,7,8,10,12...all months take 160
from start to end.it is ok
 with all cases the total it is ok now.
but still if i start as

if i start as 02/01/2006 or months 4,6,11...first value depend how many days for every month

02/01/2006 comput as 28 days
04/01/2006 compute as 30 days
06/01/2006...................
09/01/2006...................
11/01/2006...................

ex..
value=800
month=5
start date=06/01/2006
for month6
first record=154.67
last record from 11/01/2006 to 11/01/2006=5.330
------------------------------

is there a way to make all months as 30 days,

maybe 30 days solv this problem.


thanks.



>>hi all,
>>
>>any help to corret or fixit this code under,
>>
>>i have problem with month 1,2, and month 9
>>
>>if i start date as 01/01/2006 or 09/01/2006 or 02/01/2006... it works ,
>>
>>and onther months it works for all dates..
>>
>>but if i start with another date as 01/11/2006....etc for this 3 months ,1,2 and 9 i get
>>wrong compute for the first and end records at the grid,
>>
>>for month 1 and 9 increase the value ,for month2 decrase the vlaue.
>>
>>pls. try as under.
>>
>>run it as
>>value =900
>>month=5
>>start date as =01/11/2005 or 02/11/2006 or 09/11/2006.
>>
>>
>> code
>>
>>Public oForm
>>oForm = Createobject('myForm')
>>oForm.Show()
>>
>>Define Class myForm As Form
>>  DataSession = 2
>>  Height = 300
>>  Width = 480
>>
>>  Add Object label1 As Label With ;
>>    Caption = "Principal", Left = 20, Width = 50, Top = 25
>>  Add Object label2 As Label With ;
>>    Caption = "Interest", Left = 20, Width = 50, Top = 55
>>  Add Object label3 As Label With ;
>>    Caption = "Months", Left = 20, Width = 50, Top = 85
>>  Add Object label4 As Label With ;
>>    Caption = "Start", Left = 20, Width = 50, Top = 115
>>  Add Object txtprincipal As TextBox With ;
>>    Value = 100, Left = 80, Top = 25, Width = 100
>>  Add Object txtinterest As TextBox With ;
>>    Value = 0, Left = 80, Top = 55, Width = 100
>>  Add Object txtmonths As TextBox With ;
>>    Value = 12, Left = 80, Top = 85, Width = 100
>>  Add Object txtstart As TextBox With ;
>>    Value = (Date()), Left = 80, Top = 115, Width = 100
>>  Add Object cmdCalculate As CommandButton With ;
>>    Top = 145, Left = 80, Caption = "Go"
>>  Add Object grddistribution As Grid With ;
>>    Height = 280, Left = 190, Top = 5, Visible = .F., Width = 280
>>
>>  Procedure cmdCalculate.Click
>>    With Thisform
>>      lnPayment = Payment( .txtPrincipal.Value,;
>>        .txtInterest.Value,;
>>        .txtMonths.Value)
>>      Create Cursor crsDist (From d, To d, Amount Y)
>>      For ix=0 To .txtMonths.Value
>>        ldCurrent = Gomonth(.txtStart.Value,m.ix)
>>        ldFrom = Iif(m.ix = 0, m.ldCurrent, ;
>>          Date( Year(m.ldCurrent), Month(m.ldCurrent), 1))
>>        ldTo = Iif(m.ix = .txtMonths.Value, m.ldCurrent,;
>>          Gomonth(m.ldCurrent,1)-Day(Gomonth(m.ldCurrent,1)))
>>
>>lnDaysInMonth = Day(Gomonth(m.ldCurrent,1)-Day(Gomonth(m.ldCurrent,1)))
>>        Do Case
>>          Case m.ix = 0
>>            lnAmount = m.lnPayment * ((Day(m.ldTo)-Day(m.ldCurrent))/(m.lnDaysInMonth-1))
>>          Case m.ix = .txtMonths.Value
>>            lnAmount = m.lnPayment * ((Day(m.ldCurrent)-1)/(m.lnDaysInMonth-1))
>>                Otherwise
>>            lnAmount = m.lnPayment
>>        ENDCASE
>>
>>        Insert Into crsDist (From,To,Amount) ;
>>          values ;
>>          ( m.ldFrom, m.ldTo,m.lnAmount)
>>      Endfor
>>      Locate
>>      .grdDistribution.RecordSource = 'crsDist'
>>      .grdDistribution.Visible = .T.
>>    Endwith
>>  Endproc
>>Enddefine
>>
>>
>>
>>thanks.
>
>
>  Procedure cmdCalculate.Click
>    With Thisform
>      lnPayment = Payment( .txtprincipal.Value,;
>        .txtinterest.Value,;
>        .txtmonths.Value)
>      Create Cursor crsDist (From d, To d, Amount Y)
>      For ix=0 To .txtmonths.Value
>        ldCurrent = Gomonth(.txtstart.Value,m.ix)
>        ldFrom = Iif(m.ix = 0, m.ldCurrent, ;
>          Date( Year(m.ldCurrent), Month(m.ldCurrent), 1))
>        ldTo = Iif(m.ix = .txtmonths.Value, m.ldCurrent,;
>          Gomonth(m.ldCurrent,1)-Day(Gomonth(m.ldCurrent,1)))
>        Do Case
>          Case m.ix = 0
>            lnLeft = 30 - (Day(m.ldTo)-Day(m.ldCurrent))
>            lnAmount = m.lnPayment * ((Day(m.ldTo)-Day(m.ldCurrent))/30)
>          Case m.ix = .txtmonths.Value
>            lnAmount = m.lnPayment * (m.lnLeft/30)
>          Otherwise
>            lnAmount = m.lnPayment
>        Endcase
>        Insert Into crsDist (From,To,Amount) ;
>          values ;
>          ( m.ldFrom, m.ldTo,m.lnAmount)
>      Endfor
>      Locate
>      .grddistribution.RecordSource = 'crsDist'
>      .grddistribution.Visible = .T.
>    Endwith
>  Endproc
>
>PS: This is my final reply to it. Never really understood your calculation, just guessing.
>Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform