How to remove the last character from string

Posted on 2012-09-18
Last Modified: 2012-09-19
I want to remove the last character from string
Ex: I have a string 4.000% I want to remove % from string and want to use 4.000 in the code.

Question by:KavyaVS
    LVL 83

    Accepted Solution

    Simplest thing is to substring

    Dim newstr As String = oldstr.Substring(0, oldstr.Length - 1)
    LVL 83

    Assisted Solution

    If you know the character you want to remove, you can also use replace

    newstr = oldstr.Replace("%", "")
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    You can also remove specific characters from only the end with TrimEnd():

        str = str.TrimEnd("%")

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    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…

    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