hi.

i have this problem on how to calculate the amount due in our system in VISUAL BASIC.NET .
in returning module, (this is for penalty purposes), if the borrower didn't return the book on time, the system must automatically generate the amount due .
one daY is equivalent to 10(ten) pesos.
so if the borrower didn't return the book with 2 days. the amount due must be 20.00 pesos.

thank you very much to those who can answer my wonderful question..

btw..what i need is the formula.. an example code .. :)

You can do it like:

``````Const PenaltyPerDey As Decimal = 10D

Private Sub MyMethod()
Dim exired As New DateTime(2012, 4, 9)
Dim penalty As Decimal = CalculatePenalty(exired)
End Sub

Private Function CalculatePenalty(expired As DateTime) As Decimal
Dim ts As TimeSpan = DateTime.Now.Subtract(expired)
Dim totalDays As Integer = ts.Days
Return CDec(totalDays) * PenaltyPerDey
End Function
``````

I tried one method....

Assuming u will have a datetimepicker that will show the due date / it can be a label or text box also just to store the value
One label or textbox that will have a due Amount/per day that needs to be paid
last the result box to show the total amount to be paid
One button that will generate the amount

I tried the following method on button click event

`````` Dim d2 As DateTime 'will have the value for due date
Dim d3 As DateTime 'will be the current date
d2 = DateTimePicker2.Value.ToString("MM/dd/yyyy") 'formatting the date
d3 = Date.Today
Dim days As Long
days = DateDiff("d", d2, d3) 'days will contain the date difference from due date to current date
Label1.Text = days 'just storing the date difference, can comment it if u dont want
Label4.Text = Integer.Parse(days) * Integer.Parse(Label2.Text) 'will show the result of the due amount to be paid
``````

Are you storing these values in a database?

I would hope so. If not, you could possibly lose all information from power loss or application exit.

Yes this values shud be stored in database so that u wont miss the data and even in future u would need it....keep a column in database to store the values....

i only used textboxes,
i only used datetimepicker for the date of payment not in due date

like this

Does the datetimepicker contain the due date data or the current date???

In the amount text box are u going the caluclate the due amount???

The print and Save button will obvioulsy print the form but where are u saving the data???