Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VB Question

  • 26-11-2007 01:58PM
    #1
    Registered Users, Registered Users 2 Posts: 130 ✭✭


    Hi im new to VB so sorry if this is ridiculously obvious or anything but im trying to make a program where the user enters 7 numbers and the program then adds up the 6 highest numbers. I have an idea of how to do it but my way would take huge amounts of code so i was wondering if there was any quicker way of doing it.
    ty


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Whats your way?


  • Closed Accounts Posts: 345 ✭✭FindingNemo


    mrac wrote: »
    Hi im new to VB so sorry if this is ridiculously obvious or anything but im trying to make a program where the user enters 7 numbers and the program then adds up the 6 highest numbers. I have an idea of how to do it but my way would take huge amounts of code so i was wondering if there was any quicker way of doing it.
    ty

    look up ARRAYS


  • Registered Users, Registered Users 2 Posts: 130 ✭✭mrac


    My way was to just use a hell of alot of if statments, how would do do it with arrays ? (sorry i know nothing about arrays)


  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    Can you post a rough example of the code you would use to achieve your ideas.

    If you check the charter, we ask that you provide some example of what you've done. One of us giving you the answer won't help anyone :)


  • Registered Users, Registered Users 2 Posts: 901 ✭✭✭EL_Loco


    actually you can do it without arrays. you just need to track the lowest number inputted and take it away from the grand total at the end.

    now, there's the pseudo code, go VBorise it ;)


  • Advertisement
  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Let the user input the numbers, and each time they do add the number to a total (and keep a store of this) and check to see if it the smallest number entered, to date, and store it. Then at the end subtract what was the smallest number from your total.

    Two variables, one for-next loop and one conditional. About six lines of code in all.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    EL_Loco wrote: »
    actually you can do it without arrays. you just need to track the lowest number inputted and take it away from the grand total at the end.
    Damn - should have read the thread in full. Beat me to it.


  • Registered Users, Registered Users 2 Posts: 130 ✭✭mrac


    wOO I figured it out :P thaks for all your help.


Advertisement