Forum Home
Press F1
 
Thread ID: 7723 2001-02-11 12:03:00 simple Visual Basic problem Guest (0) Press F1
Post ID Timestamp Content User
8621 2001-02-11 12:03:00 im just tinkering with a little bit of vb basically doing this table with 'select case'

$
38001+ 33%
5001-38000 21%
0-5000 11%

it all works ok except for the
5001 - 38000 part

I have it as:
Case Is > 5000 <= 38000

but this does not work.. it just intreprets it as:
Case Is > 5000

so how do you get the 'greater than 5000 but less than or equal to 38000'
into VB...

my program is you enter ur wage or what ever in 'S' and it gets your tax.. 11% for first 5000, 21% for next 33000 etc... and outputs result in 'out'

entire program:

Private Sub CommandButton1_Click()

Select Case Range('S').Value

Case Is <= 5000
Range('out').Value = (Range('S').Value * 0.11)

Case Is > 5000 <= 38000
Range('out').Value = ((Range('S').Value - 5000) * 0.21) + (5000 * 0.11)

Case Is > 38000
Range('out').Value = ((Range('S').Value - 38000) * 0.33) + (33000 * 0.21) + (5000 * 0.11)

End Select

End Sub
Guest (0)
8622 2001-02-11 21:49:00 A solution is to alter the order of your Cases.
Case one is <= 5000
Case two is >38000
Case Else is the between formula.

HTH
Guest (0)
8623 2001-02-12 02:26:00 it worked fine but what would happen if you had 4 constraints..

like one upper and one lower limit (like before) but then two 'in between' constriants

how would you do that?
Guest (0)
1