Rounding number

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
 
V

Van T. Dinh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top