borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Refresh DataSet after undeleteing a row)Next Topic (problem in delete records from database...!) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Help Solved Topic
Poster Message
Tom Ojo
Level: Trainee

Registered: 20-02-2009
Posts: 3

Ads by Lake Quincy Media
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 1060
icon Re: Help

Hi
What bit are you stranded on? Which version of VB.Net are you using 2005 or 2008?
What have you tried? Are you having difficulty with the math?

You are more likely to get assistance with a specific question rather than "How do i write an application"..

Regards
Kieron

____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

Ads by Lake Quincy Media
23-02-2009 at 12:10 AM
View Profile Send Email to User Show All Posts | Quote Reply
Tom Ojo
Level: Trainee

Registered: 20-02-2009
Posts: 3
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 1060
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
Tom Ojo
Level: Trainee

Registered: 20-02-2009
Posts: 3
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 1060
icon Re: Help

No worries. There's loads of people on this forum who love to help. Please keep creating your topics.

If this issue is solved, please mark it as solved using the link at the bottom.



____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

24-02-2009 at 06:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : Help Solved Topic
Previous Topic (Refresh DataSet after undeleteing a row)Next Topic (problem in delete records from database...!) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder