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.

Simple visual basic question

  • 23-11-2006 02:26PM
    #1
    Closed Accounts Posts: 29,930 ✭✭✭✭


    At least, simple for those that know it. I have to write a basic program to determine what rate someone is due on their investment, from a table like:

    <5000 = 2%
    5000 - <10000 = 3%
    10000 - <50000 = 4%

    And so on so forth. I have to write it using the select case statement though, and I don't know how to do this. I've looked up things online and can't make any real sense of them or shed any light on how to do it. I can write a program that does the same thing using the If statement but that won't really do...just wondering if somebody could show me a line or two showing how it works?

    Any help appreciated. thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 1,193 ✭✭✭liamo


    Without solving your specific problem, here's an example ....
    Select Field1, Field2, Field3, 
      Case 
       When Field4=100 Then 
        1 
       When Field4>200 Then
        2
       When Field4<500 Then
        3
       End
       As Field4
    From MyTable
    

    Hope this helps.

    Liam


  • Closed Accounts Posts: 82 ✭✭cyberbob


    thats some funny looking VB . :p


  • Moderators, Music Moderators Posts: 23,365 Mod ✭✭✭✭feylya


    Dim interest
    Select Case number
        Case < 5000
            Interest = 0.02
        Case < 10000
            interest = 0.03
        Case < 50000
            interest = 0.04
        Case Else
            'Whatever
    End Select
    

    The first answer in google showed that...


  • Registered Users, Registered Users 2 Posts: 1,193 ✭✭✭liamo


    cyberbob wrote:
    thats some funny looking VB . :p

    I was working in SQL Query Analyser at the time and thought ...... Heh, well it's obvious what I thought. That'll teach me! :D

    HavoK, sorry for giving you the wrong information. Big oops.

    Liam


  • Closed Accounts Posts: 29,930 ✭✭✭✭TerrorFirmer


    feylya wrote:
    Dim interest
    Select Case number
        Case < 5000
            Interest = 0.02
        Case < 10000
            interest = 0.03
        Case < 50000
            interest = 0.04
        Case Else
            'Whatever
    End Select
    

    The first answer in google showed that...

    Thank you very much, appreciated. I looked up case select in Google and even though I was desperately looking for an example like above, I couldn't find anything I could understand. Thanks again.


  • Advertisement
Advertisement