Hoe to format a double datatype

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

cmdolcetAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
game-masterConnect With a Mentor Commented:


try something like this...

Debug.Print(Format(PositionValue1 , "00.00"))
0
 
rgn2121Commented:
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
 
CodeCruiserCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.