• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Stripping out characters...

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:

301C0M030701-A

Any help would be appreciated!  Thanks!
0
johnqtr
Asked:
johnqtr
2 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
Try this:

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

Hope it helps.
0
 
gregoryyoungCommented:
dim LotNumber as string = "301C0M030701-A-2"
if LotNumber.Length > 1
    LotNumber = LotNumber.SubString(0, LotNumber.Length -2)
end if
0
 
gregoryyoungCommented:
or you can just use a left() operation in your query if this data is being returned from a sqlserver etc
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RealMrTeaCommented:
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.

Later,
Eric
0
 
johnqtrAuthor Commented:
Sorry, I meant to give the first post 125 points.  Sorry.
0
 
gregoryyoungCommented:
unaccepted per your request.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now