Solved

Excel formatting

Posted on 1998-11-04
4
125 Views
Last Modified: 2010-04-30
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.
0
Comment
Question by:lesa
  • 2
4 Comments
 
LVL 9

Expert Comment

by:david_levine
ID: 1443130
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
0
 
LVL 3

Accepted Solution

by:
tcurtin earned 10 total points
ID: 1443131
Try Value = format(xlSheet.Cells(1, 1),"#.000")
This will force 3 decimals.
0
 

Author Comment

by:lesa
ID: 1443132
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.
0
 
LVL 3

Expert Comment

by:tcurtin
ID: 1443133
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
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Vlookup to move data back to source. 4 90
Visual Basic Excel Formatting error 4 105
message box in access 4 46
Prevent user closing word document opened with VB6 6 74
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question