Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hoe to format a double datatype

Posted on 2009-07-15
3
Medium Priority
?
205 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 1000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

722 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