'Visual Basic 2008/2010 Nut van OOP Object Oriented Programming Module Client3 Dim count As Integer Dim capacity As Integer = 16 Dim loans(2, capacity - 1) As Decimal Sub Main() ' add three loan-datagroups to collection AddLoan(1000, 5, 24) AddLoan(5000, 10, 10) AddLoan(10000, 2, 24) ' remove the second loan-datagroup from the collection RemoveLoan(1) ' get total and monthly payments for all loans : For index As Integer = 0 To count - 1 Dim amount As Decimal = loans(0, index) Dim intrestRate As Decimal = loans(1, index) Dim monthDuration As Integer = loans(2, index) Console.WriteLine(GetTotalPayment(amount, intrestRate) & " " & _ GetMonthlyPayment(amount, intrestRate, monthDuration)) Next ' Console.ReadLine() End Sub Sub AddLoan(ByVal amount As Decimal, ByVal intrestRate As Decimal, _ ByVal monthDuration As Integer) If count = capacity Then capacity *= 2 ReDim Preserve loans(2, capacity - 1) End If loans(0, count) = amount loans(1, count) = intrestRate loans(2, count) = monthDuration count += 1 End Sub Sub RemoveLoan(ByVal index As Integer) Dim shiftIndex As Integer For shiftIndex = index To count - 2 loans(0, shiftIndex) = loans(0, shiftIndex + 1) loans(1, shiftIndex) = loans(1, shiftIndex + 1) loans(2, shiftIndex) = loans(2, shiftIndex + 1) Next loans(0, shiftIndex) = 0 loans(1, shiftIndex) = 0 loans(2, shiftIndex) = 0 count -= 1 End Sub Function GetTotalPayment(ByVal amount As Decimal, _ ByVal intrestRate As Decimal) As Decimal GetTotalPayment = amount * (1 + intrestRate / 100) End Function Function GetMonthlyPayment(ByVal amount As Decimal, _ ByVal intrestRate As Decimal, _ ByVal monthDuration As Integer) As Decimal GetMonthlyPayment = GetTotalPayment(amount, intrestRate) / monthDuration End Function End Module 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.