Solved

Hoe to format a double datatype

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now