CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2011

    calculating commission in VB

    I'm really new to VB. This is only the 3 app I've created, and I'm stuck.

    I need to code an app that displays total commission earned on sales at different levels. The commission percentage goes up as sales go up.

    Should I write a If/else/else/else/else/then statement or something else?

    There are 5 different commission levels in the problem. I have my interface designed, but obviously that's the easy part.

    Any help would be appreciated.

  2. #2
    Join Date
    Jun 2005
    JHB South Africa

    Re: calculating commission in VB

    you can use a select case to get what percentage value the commission should be..
    Select case sales
        case < 500
            comper = .05
        case < 1000
            comper = .07
        case < 2000
            comper = .09
        case else
            comper = .10
    end select
    Commission = sales * comper
    It works almost the same as an If Else/else/else but is a little cleaner and easier to adjust at a later time..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Feb 2014

    Re: calculating commission in VB

    I am brand new to VB and I am also working on a commission project. I was going to use the if/else/else/then as mentioned above but could not figure out exactly where to place it in the code. I want the commission to be calculated when the btnCalc button is clicked so I thought it should go within that declaration but it doesn't work.

    I like the idea of using the Select case method as described by GremlinSA but that still leaves e with where does it fit in the code.


  4. #4
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: calculating commission in VB

    Why not just create a new function and call it from within the Button_Click event!
    Pass it the variable to choose from. ComputeCalc(myValue)

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Feb 2014

    Re: calculating commission in VB

    I tried that but there are 3 different levels of commissions depending on the amount of sales made. The commission structure is:
    = < 100000 is 2%
    >100000 but < 400000 is 2000 + 5% of everything over 100000
    >400000 is 17000 + 10% of everything over 400000

    I thought I had it working but the 5% carried over into the next option so instead of getting 10% of everything over 400000 it was only showing 5%. I have no idea why the 2% did not carry over into the second option but the 5% did carry over to the third.

    Thank you for your reply. It will be very helpful if I can figure out how to fix the multiplication problem.

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: calculating commission in VB

    It would help if you showed the code you tried.

    in the first case you would just take the percentage of the value
    in the next case you would subtract 100000 from the value and then do the percentage on the remainder and add 2000 to that number
    in the final case it would be the same except you would be subtracting 400000 from the total and doing the percentage on that remainder and adding the 17000 to that number

    Something like
    Select case TotalVal
        Case < 100001
       Case < 400001
       Case Else
    End Select
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Feb 2014

    Re: calculating commission in VB

    Thanks DataMiser,
    I actually understood what you were suggesting and was able to use the code to finish the project.

    Sorry it took me so long to get back here to rate your post and say think you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.