Solved

Excel formatting

Posted on 1998-11-04
4
128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

737 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