Solved

Hoe to format a double datatype

Posted on 2009-07-15
3
202 Views
Last Modified: 2012-05-07
I trying to format the PositionValue1 inside a text file. I want the calculated value in PositionValue1 to only show "xx.xx" decimal places. I tried the ToString methode however that only return the values of "00.00"
Public PositionValue1 As Double
 
PositionValue1 = CStr(_12ArrayList_Position(intInnerLoop))
                    strText += PositionValue1 & vbTab & CStr(_12ArrayList_Completed(intInnerLoop)) & vbCrLf

Open in new window

0
Comment
Question by:cmdolcet
3 Comments
 
LVL 12

Expert Comment

by:rgn2121
ID: 24866147
If the data is coming in as a string, then you could do double.parse(myString).  Not sure if that will drop the ending decimals if they are zero though...
0
 
LVL 13

Accepted Solution

by:
game-master earned 250 total points
ID: 24866519


try something like this...

Debug.Print(Format(PositionValue1 , "00.00"))
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24867694
If showing only two digits after decimal point is what you are trying to do, then use the Math.Round function

Math.Round(123.3211, 2) ' would be 123.32
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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