Solved

Hoe to format a double datatype

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

932 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

9 Experts available now in Live!

Get 1:1 Help Now