Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Case? in VB

Options
  • 22-11-2002 1:00pm
    #1
    Registered Users 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 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