Link to home
Start Free TrialLog in
Avatar of lesa
lesa

asked on

Excel formatting

I am using excel as Object in VB 5.0. I am getting the values of the cell in excel as
Value = xlSheet.Cells(1, 1). But the problem is if the excel cell is having 123.450
as the value it is returning 123.45 instead of 123.450. I want to get 123.450 from the excel and as well I want the excel to save the file with 123.450 instead of 123.45 as it normally does.

Can anybody help me out in this issue.
Avatar of david_levine
david_levine

Well, you can't really... cause you are retreiving the value of the cell and that value doesn't have the trailing zero. It shows like that because of the format statements. I'm not 100% sure how to retrieve the format statements if you need to, but you should be able to show it that way in VB with an appropriate edit mask.

David
ASKER CERTIFIED SOLUTION
Avatar of tcurtin
tcurtin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lesa

ASKER

I have no fixed decimals to make use of the above format. What all I want is if the user enters 123.450 it should save like that instead of 123.45. The decimals may vary like 123.4560 then it should save as 123.4560 instead of 123.456.
looks like you want floating zeros. Why would you like a zero on the end if there are no values in that column? You could use the 'lostfocus' event to set the value:

text1.text = text1.text & "0"

That way you will always append a zerol