Trouble copying numerical data from an Excel spreadsheet.

villartech
villartech used Ask the Experts™
on
I am using the following code to read numerical data from an Excel spreadsheet to a string variable.

dim amount as string

Set xLApp=new Excel.application
Set wb=xLApp.Workbooks.open(FileName)
set ws=wb.Worksheets("Sheet1")

amount=cells(row,col).value

wb.close
xLApp.quit
sett ws=Nothing
set wb=Nothing
Set xLapp=Nothing

The problem is that it is dropping the zeros in the cents portion of the number.
So if the Excel cell data is 100.20 then amount variable is 100.2
Or if the Excel cell  data is 100.00 then amount variable = 100.

I need to be able to read the whole number.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try

amount=cells(row,col).value
How about you just use the format function:
amount=format(cells(row,col).value,"#.00")
Oops I did not change it

amount=cells(row,col).text

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial