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.

Case? in VB

  • 22-11-2002 01:00PM
    #1
    Registered Users, Registered Users 2 Posts: 446 ✭✭


    I was using an IF statement inorder to put a discount on if 2 or more people enrolled.

    It's basically if 2 or more enroll then 10% off and 3+ is 15%


    I had an if statement like this:

    If mintNumBusinessClicks = 2 Then
    mcurDiscount = 10
    Else
    If mintNumBusinessClicks >= 2 Then
    mcurDiscount = 15
    etc etc

    It worked perfectly but the teacher said that it would be easier to use Select Case. Which I understand to the extent where If the user clicks on for e.g the 1st item in the listbox and Case 0 is "caption. = "1" then it'll print 1 and so on.

    However because I need to tell whether there was 2 or more and have 2 parts to each case? How would I go about that?

    Thanks
    Kate


Comments

  • Registered Users, Registered Users 2 Posts: 2,494 ✭✭✭kayos


    here you go
    Select Case mintNumBusinessClicks
        Case 2
            mcurDiscount = 10
        Case Is > 2
            mcurDiscount = 15
    End Select
    


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Yes. It's woth noting that Select Case in VB is quite different to the equivalent in other languages (many of which only allow matches against constants, not against ranges).


Advertisement