views:

23

answers:

1

I am trying to add to a page that someone else has written. I need to take a string that is formated with either 3 or 4 alpha characters followed by a series of numbers. I need to remove these alpha characters so that only a string of numbers is left.

Example: What I'm string with is TrailerNumber = "CIN0012345" and I need the result to be TrailerNumberTrimed = "0012345"

This is a web application written in an ASP (to be clear not ASPX) and VB page. This code will have to run on the server because it is being used as a search value in a database.

A: 

Not tested, but should work (assuming start of string is always 3/4 alpha followed by all numbers):

Dim TrailerNumberTrimed 

If IsNumeric(Right(TrailerNumber, Len(TrailerNumber) - 4)) Then
    TrailerNumberTrimed = Right(TrailerNumber, Len(TrailerNumber) - 4)
End If

If IsNumeric(Right(TrailerNumber, Len(TrailerNumber) - 3)) Then
    TrailerNumberTrimed = Right(TrailerNumber, Len(TrailerNumber) - 4)
End If

' At this point, you should have the correct trimmed trailer number
Oded
Thank you, this worked like a charm.
GeekIT1001