Solved

Excel formatting

Posted on 1998-11-04
4
124 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now