 |
Tom Ojo Level: Trainee
 Registered: 20-02-2009 Posts: 3
|
Help
Hello there,
PLEASE HELP ME OUT!!!!!!!!!
I am a college student trying to get my hands around some stubborn VB.Net questions. Here is the question below I need a help as I am stranded at the moment. I am using VB.Net 2005/2008 version.
A manufacturere of sawn timber sells to a large number of timber yards and DIY shops. Assume the user is processing payments from these customers. Allow the users to input the date an invoice should have been pain by and the total value of the invoice. Calculate how many dyas late, if any, the payment have been made. If payment has been made 15 days before the due date give 10% discount, otehrwise tive 5% discount if it has been paid on time. Output details about whether payment has been made on time, any discount given and the total amount due.
|
|
20-02-2009 at 04:28 PM |
|
|
Tom Ojo Level: Trainee
 Registered: 20-02-2009 Posts: 3
|
Re: Help
Hi Kieron,
Thank you for getting back to me. As stated in your reply:
I am working with Visual Basic.Net 2005 Version
My main bottle neck is the Maths aspect of it.
Also, if you have the chance you can help me with few tips on how the design of the interface should look like but if not I will be able to find my way around if I can get idea of the maths.
Thank you.
Tom Ojo
|
|
23-02-2009 at 09:40 AM |
|
|
stickleprojects Level: Moderator

 Registered: 09-09-2002 Posts: 1060
|
Re: Help
Hi,
I've written you a function in VB to do the Math - as requested:
Private Function CalculateDiscount(ByVal dblInvoiceAmount As Double, ByVal dtInvoiceDueDate As Date, ByVal dtDateInvoicePaid As Date, ByRef dblDiscount As Double, ByRef intDaysLate As Integer, ByRef dblAmountDue As Double) As Boolean
''Calculate how many dyas late, if any, the payment have been made.
''If payment has been made 15 days before the due date give 10% discount,
'' otehrwise tive 5% discount if it has been paid on time
'' Output details about whether payment has been made on time,
'' any discount given and the total amount due.
'' Returns TRUE if everything was ok
Dim blnOk As Boolean ' Return value = set to true if all ok
Dim dblDiscountPerc As Double
' How many days late/early is the payment?
intDaysLate = DateDiff(DateInterval.Day, dtInvoiceDueDate, dtDateInvoicePaid)
' if paid late or on time then no discount
If intDaysLate >= 0 Then
dblDiscount = 0.0
Else 'paid early
' if paid more than 15 days early, then 15% discount
If intDaysLate < -15 Then
dblDiscountPerc = 15.0
Else
' otherwise, it's 5% discount
dblDiscountPerc = 5
End If
dblDiscount = dblInvoiceAmount * (dblDiscountPerc / 100)
End If
' Calculate amount due
dblAmountDue = dblInvoiceAmount - (dblDiscount)
blnOk = True
' Return to calling application
Return blnOk
End Function
|
I've added a load of comments - so I hope it's self-explanatory.
Also find attached a working vb.net project so you can see this in action. I hope this gets you started.
Just realised I am giving 15% discount, no 10%. See if you can spot the mistake and correct it 
[Edited by stickleprojects on 23-02-2009 at 10:18 PM GMT]
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
____________________________ Attached:
AndreaVB_TestDiscount.zip 16 KB (Downloads: 8)
|
|
23-02-2009 at 10:16 PM |
|
|
Tom Ojo Level: Trainee
 Registered: 20-02-2009 Posts: 3
|
Re: Help
Hi Kieron,
I am extremely grateful. I would be pleased to be a wizard like you!!!!!!!!!! What tips can you give me, this programming is an area I wanted to know and master very well.
You are a good source of inspiration to other learners like me!!!!!!!! A good example to follow.
Thank you & God bless.
Tom
|
|
24-02-2009 at 11:06 AM |
|
|
|
|
 |
 |