Solved

Hoe to format a double datatype

Posted on 2009-07-15
3
203 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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