i want to populate the datagrid1 based on the given value below. i'm using VB6 as my frontend and MSACCESS as my backend.

how to accomplish this?

NET 9,500.00 'Given value
INTEREST 1,200.00 'Given Value
INT DUE 48 'Given Value
IRR 0.69867 'Given Value
TERM 25 'Given Value
RELEASE 05/02/06 'Given Value

BB INT DA

8,800.00 61.48 13.48
8,813.48 61.58 13.58
8,827.06 61.67 13.67
8,840.73 61.77 13.77
8,854.50 61.86 13.86
8,868.36 61.96 13.96
8,882.32 62.06 14.06
8,896.38 62.16 14.16
8,910.54 62.26 14.26
8,924.79 62.35 14.35
8,939.15 62.46 14.46
8,953.60 62.56 14.56
8,968.16 62.66 14.66
8,982.82 62.76 14.76
8,997.58 62.86 14.86
9,012.44 62.97 14.97
9,027.41 63.07 15.07
9,042.48 63.18 15.18
9,057.66 63.28 15.28
9,072.94 63.39 15.39
9,088.33 63.50 15.50
9,103.83 63.61 15.61
9,119.43 63.71 15.71
9,135.15 63.82 15.82
9,150.97 63.94 15.94

here is my code modified code from purplegerbil:

Private Sub Command1_Click()

Dim i As Integer
Dim myDate As String
Dim tempbb As Currency
Dim da As Currency
Dim intdue As Currency
Dim netbb As Currency
Dim tempda As Currency
Dim enddingbal As Currency

intdue = (INTEREST / TERM)

List1.Clear
List1.AddItem RELEASE
AdoRange.Recordset.AddNew
DataGrid2.Columns(0) = lblID.Caption
DataGrid2.Columns(1) = RELEASE
DataGrid2.Columns(2).Value = NET 'bb get the first row
DataGrid2.Columns(3).Value = Round(DataGrid2.Columns(2).Value * Val(txtIRR.Text) / 100, 2) 'computation for int
DataGrid2.Columns(4).Value = Round(DataGrid2.Columns(3).Value - intdue, 2) 'computation for DA

tempbb = Val(DataGrid2.Columns(2).Value)
tempda = Val(DataGrid2.Columns(4).Value)

For i = 1 To TERM - 1

AdoRange.Recordset.AddNew
enddingbal = tempbb + tempda
netbb = enddingbal 'BB
intbb = netbb * Val(txtIRR.Text) / 100 'INT
da = intbb - intdue 'DA
myDate = DateAdd("d", 7 * i, RELEASE)
List1.AddItem myDate

DataGrid2.Columns(0) = lblID.Caption
DataGrid2.Columns(1) = myDate
DataGrid2.Columns(2).Value = netbb
DataGrid2.Columns(3).Value = Round(intbb, 2)
DataGrid2.Columns(4).Value = Round(da, 2) 'computation for DA

Next i

End Sub

what's wrong with the code?

see the attach file: the output of the code above. the first 2 rows are correct but the 3rd till last wrong.

thanks in advance....

Recommended Answers

All 2 Replies

Hi,

Had a quick look at the code, endingbal = tempbb+tempda.
This figure will always be the same because tempbb and tempda are set out of the for...next loop.

You may need to add something like endingbal = (tempbb+tempda)*i
to increment the value.


pG

thanks for the reply. i found the error on loop but it's ok now. thanks...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.