Join 149,499 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,383 people online right now. Registration is fast and FREE... Join Now!
Are you using ASP, or ASP.NET? Also, is there a possibility that there will be other zeros in the string that you need to keep? If so, there is no specific function in classic ASP to trim specific characters, but you can use the Replace function in conjunction with the InStr function to eliminate the leading zeroes. Another possibility is the use of one of the conversion functions if the string is comprised of only digits.
Are you using the ASP.NET functionality only, or are you using any VB.NET/C# as well on the page? Sorry for the questions, but if using one of those languages, we can use the String object.
Actually, i'm not sure...TrimStart is meant to remove that character from the beginning...not sure if it will do it multiple times. you may also have to convert the parameter to a char array before feeding it to the TrimStart method.
ok, let me ask, in the event that my method doesn't work, what are your thoughts on how to proceed with trimming the leading zeros? (just for future reference)
Well, the brute force way would be to traverse the string starting at the beginning - if the character at the specified index is a "0", remove (or replace with nothing), and break out of the loop the first time you hit a character is not a zero. another way to do it would be to use the Replace function to change all the zeroes to spaces, then use the LTrim function to get rid fo those spaces, then use the Replace function again to reconvert the remaining spaces to zeroes.