Stripping out characters...

Posted on 2005-04-25
Last Modified: 2010-04-23
I have a dropdownlist box that displays a "LotNumber" and I need to stripout the last two characters.  e.g.

Example LotNumber = 301C0M030701-A-2

I need the dropdownlist box to display:


Any help would be appreciated!  Thanks!
Question by:johnqtr
    LVL 52

    Assisted Solution

    by:Carl Tawn
    Try this:

            Dim LotNumber As String = "301C0M030701-A-2"
            LotNumber = LotNumber.Remove(LotNumber.Length - 2, 2)

    Hope it helps.
    LVL 37

    Accepted Solution

    dim LotNumber as string = "301C0M030701-A-2"
    if LotNumber.Length > 1
        LotNumber = LotNumber.SubString(0, LotNumber.Length -2)
    end if
    LVL 37

    Expert Comment

    or you can just use a left() operation in your query if this data is being returned from a sqlserver etc
    LVL 7

    Expert Comment

    Just an idea for you.

    You could place the text in a custom object and then override the ToString() method to perform the above string operations.  This would allow you to take the text from the database and store it directly in an object and then place it in a control and get exactly the output you want.


    Author Comment

    Sorry, I meant to give the first post 125 points.  Sorry.
    LVL 37

    Expert Comment

    unaccepted per your request.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    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…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    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

    13 Experts available now in Live!

    Get 1:1 Help Now