How to TRIM zeroes from the left portion of a string

Classic ASP VBScript
DWMX/CS3
WIN XP Pro

Hello.

I have a login page for our team where a user enters their employee number.  Sometimes, however, they enter their "full" employee number, which just contains 3 leading zeroes ("000.....") before their number.

This, of course, causes problems when logging in because the entered datat does not contain the leading zeroes.

I would like for any zeroes to the left of a number to be ignored, or removed, from the login after the user presses "submit".  I was looking at TRIM, LTRIM, RTRIM, but they appear to just remove spaces.

How could I accomplish removing/ignoring zeroes?

Example emp number:  203456
Example login (Sometimes): 000203456

Basically, I would like any number of zeroes (Whether 2 or 5, etc.) to be removed/ignored from the left side until it reaches any number other than zero.


Thanks so much,
Shane
lshaneAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Dim x
x="000123"
x = CInt(x)
0
lshaneAuthor Commented:
Thanks, hielo, for your reply.  That's kind of what I need.  More specifically, though, I need to remove any number of zeroes in the front before a "different" number appears.

Sometimes a user could enter "00123456"...
Other times they could enter "000123456"...
Or even "0123456"...

I just want to be able to have it ignore/remove any zero (however many) in the beginning of the string UNTIL it hits the first "different" number (1, 2, 3, 4, etc.).

Is that possible?
0
hieloCommented:
That's effectively what CInt() will do. Did you try it? If you are having problems then add zero the result of CInt():

Dim x
x="000123"
x = 0 + CInt(x)

x should now be just 123
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

lshaneAuthor Commented:
Hello, hielo.

OK - yes, it did work - to a certain degree.

However... if I type "000123456" or even "123456" then I get the following error:
********************************************************
Error Type:
Microsoft VBScript runtime (0x800A0006)
Overflow: 'CInt'
/testpmcct2/testloginresults.asp, line 5


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 2.0.50727)

Page:
POST 42 bytes to /testpmcct2/testloginresults.asp

POST Data:
username=123456&password=test&Submit=Login
****************************************************************

It's almost like it gives the error if I type MORE than 5 numbers other than zero.
True:  It does remove any zeroes from the beginning, however, it only accepts a 5-digit number after that.

How can that be extended?
0
lshaneAuthor Commented:
Hi, hielo.

I discovered if I remove the "C" from the "Cint", that it is able to extend the numbers.

So, what is the significance of the "C" in "Cint" ?

0
hieloCommented:
http://www.w3schools.com/VBScript/vbscript_ref_functions.asp
CInt: Converts an expression to a variant of subtype Integer
Int:        Returns the integer part of a specified number


CLng would have also given you a bigger range
0
lshaneAuthor Commented:
Awesome!  Thanks so much, hielo!  I appreciate it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.