How to convert values

Posted on 2012-09-19
Last Modified: 2012-09-19
I need to convert a value from 2.00 to 0200 the same can be said for 10.00 to 1000

I also need to know how I can change a text string so if the incoming text string is say "Point 1" and I need it to have 16 characters How could I change it to have "Point 1         "

All these variables are String datatypes.

Thanks in advance
Question by:cmdolcet
    LVL 83

    Assisted Solution

    >for 10.00 to 1000

    .Replace(".", "")


    > say "Point 1" and I need it to have 16 characters How could I change it to have "Point 1         "

    .PadRight(16, " ")


    Author Comment

    how can I change the 2.00 to 0200?

    Author Comment

    Sorry I wasn't as clear as possible on the second example. I need to have 16 characters in total, so If I have the Example "Point 1" ( 7 characters) I need to add in (9) spaces after the 1.

    However the name could be anything how could I easy count the number characters and apply the remaining set of spaces to the total of 16 characters.
    LVL 83

    Expert Comment

    PadRight function will pad enough number of spaces to make it long enough (given number of characters).

    For 2.00 to 0200, I think you would remove . and then use PadLeft(4, "0") to add 0 at start.

    Author Comment

    OK so for example the value 2.00 or 10.00 I need for it to be shown as 0200 or 1000

    I have the following code:

     If USL.Contains(".") Then
                                    USL.Remove(2, 0)
                                    USL.PadLeft(4, "0")
                                End If

    Which will do nothing on changing the string.
    LVL 83

    Accepted Solution

    I would change that code to

    USL = USL.Replace(".", "").PadLeft(4, "0")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now