View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Retrieve value using vb6 from an excel workbook - precision question

Andrew,

I think that your conclusions are correct.

Rounding and ceiling is the obvious solution, but don't forget that there
are worksheetfunctions to call upon, such as Round, Roundup, etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"CodeMonkey" wrote in message
oups.com...
Hi All
I have a Vb6 app from which I am retreiving a value in a cell in a
worksheet in a workbook.

The code goes something like this:

SomeLabel.caption = MyCells(rownum,colnum).value

Looking directly at the cell in the workbook, I see a value of 3.

However when I debug.print or msgbox MyCells(rownum,colnum).value from
the vb6 app, I find that the value is actually more like 2.9999889889
or something similar.

Whether I format the cell in the workbook as a number to 0 decimal
places, or as General, makes no difference. I conclude from this that
the vb6 code is actuall retrieving the excel *stored* value rather than
the excel *presented* value. Is this correct? How do I retrieve the
value "3" rather than the entire floating point value? Or is the only
way to coerce the data type in the vb6 app using a ceiling like
function or declaring a variable as type integer and assigning it?

Any help appreciated.

Regards
Andrew