Rounding number

  • Thread starter Thread starter Jason Frazer
  • Start date Start date
J

Jason Frazer

I have some VB code that does some calculations and stuff.
I need to round the number set to SRD an example if. If
SR = 88.12345 then SRD should equal 88.1.
Here is part of my code. I must be using the round
function incorrectly becasue it would give me a valvue
like 89. What am i doing wrong? How can I do this?

Dim SR, SRD As Integer
SR = (S1 + S2 + S3 - S4)
SRD = Round(SR, 1)
[Sufficiency Rating] = SRD

Thanks for your time and help
Jason Frazer
 
You declared SR and SRD as Integer which only store whole number. Thus:

SR = (S1 + S2 + S3 - S4)

will round the number and store the value in SD.

Change the Dim to Single or Double as appropriate.
 
Back
Top