Format String

Posted on 2009-04-20
Last Modified: 2013-11-26
How can I format the CStr(_PositionReadingArraylistValidated(intInnerLoop)) and the CStr(_ReadingArrayList3(intInnerLoop)) to 4 decimal places????
For intInnerLoop = 0 To _partfile.gageList.Count - 1

                    valuetemp1 = _PositionReadingArraylistValidated(intInnerLoop)

                    valuetemp2 = _ReadingsArraylistValidated(intInnerLoop)

                    valuetemp3 = valuetemp2 - valuetemp1

                    strText += CStr(_PositionReadingArraylistValidated(intInnerLoop)) & vbTab & valuetemp2 & vbTab & CStr(_ReadingArrayList3(intInnerLoop)) & vbTab & valuetemp3 & vbCrLf


Open in new window

Question by:cmdolcet
    LVL 48

    Expert Comment

    You can try

    LVL 83

    Expert Comment

    Another option is to use the Match.Round function on the numbers themselves.

    Author Comment

    jp,when i change the code around i get an error: Value of type String cannot be converted to System.IformatProvider.

    using: CStr(_ReadingArrayList3(intInnerLoop)).ToString("0.0000")
    LVL 48

    Accepted Solution

    Try this way:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    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…

    760 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