Need to remove zeros infront of Data

Posted on 2007-10-17
Last Modified: 2013-11-18
Hi, I am working with textfieldparser and at first it was giving this error "String or binary data would be truncated. The statement has been terminated." Then I increased that size of the fields and now I am getting some zeros infront of my data, I need to get rid of them.  Please show me an example of how to remove this zeros.

Question by:vielkacarolina1239
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    "I am getting some zeros infront of my data, I need to get rid of them."

    So you are dealing with strings then right?...and "textfieldparser" suggests you are using VB.Net 2005?

    Use the String.TrimStart() method:

        Dim str As String = "0000043.12"
        str = str.TrimStart("0")
    LVL 65

    Accepted Solution

    In VB, VAL(AnyStringWithZeros) will return AnyStringWithZeros, without leading or trailing zeros.

    Author Comment

    Yes I am using 2005

    Author Comment

    Thanks this solved the problem.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article will show, step by step, how to integrate R code into a R Sweave document
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now