By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,564 Members | 906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,564 IT Pros & Developers. It's quick & easy.

Help! Rounding up!

P: 44
HELP! I have a text box that rounds up a value. The code used is:
Expand|Select|Wrap|Line Numbers
  1. Select Case Salary
  2.     Case 10000 To 99999
  3.         fRoundSalary = CLng(Fix(curSalary) / 1000) * 1000
  4.     Case 100000 To 999999
  5.         fRoundSalary = CLng(Fix(curSalary) / 10000) * 10000
  6.     Case Else
  7. End Select
It works and rounds $31,179.20 to $31.000, but what if I need it to round up and give me an output of $32,000? Is it possible? And how should it be coded?
May 24 '07 #1
Share this Question
Share on Google+
5 Replies

theaybaras
P: 52
Someone better than me will need to answer your question, but I think 31499 and under will round to 3100 and 31500 and up will round to 32000, I haven't been able to find a way around that... good luck! I'll be watching to see if anyone knows this for sure! :)

theAybaras
May 24 '07 #2

ADezii
Expert 5K+
P: 8,750
HELP! I have a text box that rounds up a value. The code used is:
Select Case Salary
Case 10000 To 99999
fRoundSalary = CLng(Fix(curSalary) / 1000) * 1000
Case 100000 To 999999
fRoundSalary = CLng(Fix(curSalary) / 10000) * 10000
Case Else
End Select
It works and rounds $31,179.20 to $31.000, but what if I need it to round up and give me an output of $32,000? Is it possible? And how should it be coded?
Expand|Select|Wrap|Line Numbers
  1. (CLng(Fix(curSalary) / 1000) * 1000) + 1000
May 24 '07 #3

NeoPa
Expert Mod 15k+
P: 31,770
Expand|Select|Wrap|Line Numbers
  1. Dim lngRound As Long
  2.  
  3. Select Case curSalary
  4.     Case 1000 To 9999
  5.         lngRound = 100
  6.     Case 10000 To 99999
  7.         lngRound = 1000
  8.     Case 100000 To 999999
  9.         lngRound = 10000
  10.     Case 1000000 To 9999999
  11.         lngRound = 100000
  12. End Select
  13. fRoundSalary = ((curSalary + lngRound - 1) \ lngRound) * lngRound
May 25 '07 #4

P: 44
Expand|Select|Wrap|Line Numbers
  1. (CLng(Fix(curSalary) / 1000) * 1000) + 1000
Thank you! Thank you! It worked!
May 25 '07 #5

ADezii
Expert 5K+
P: 8,750
Thank you! Thank you! It worked!
Glad we were able to help you.
May 25 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.