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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple visual basic question

  • 23-11-2006 2: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,363 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