Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting .CSV File

Status
Not open for further replies.

richrock316

Programmer
Jul 30, 2003
57
US
My program creates a .CSV file and outputs 20 or so fields to it. The problem is that in the .CSV file it sets all the fields to a "general" category. This means when I wanted a value of 115.200, I get 115.2 . Is there any way of formatting it from code to include the proper amount of decimal places.

Currently I am using a format of: Format(ITIME , ".000")
 
I would use 'MyField = Format(MyValue, "###.000")'

Though other members may have a different approach.

Alan



[gray]Experience is something you don't get until just after you need it.[/gray]
 
Alan,

I still get the same results. It won't keep the trailing zeros.

Richard
 
Richard,
I suspect you are opening the file with Excel. If so it is Excel that is removing the zeros.

If you open the file with Notepad you will see that the zeros are actually included.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Alan,

Yes I am using Excel to open it. It is how the user will open it.

Richard
 
Richard

Sorry but the only way round it that I know of is to format the Excel cell to 'Number' with 3 decimal places.

Hopefully somebody else will chip in with a better solution.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top