Most efficient way to strip leading zeros from string 
Author Message
 Most efficient way to strip leading zeros from string

Hi,

I'm a former FoxPro programmer working on a VB utility.
I'm hoping that somebody could suggest the best way to
take a six character string (ie: "015676"), strip the
leading zero(s) and end up once again with a character
string.
Through FoxPro I would have probably done a substr() and
include some code to pull out everything to the right of
the first zero in the string but I'm not very familiar
with VB Syntax and commands yet. I am working on it
though.....
Any sugesstions would be greatly appreciated.

Thanks.

PS. If I should have posted this in another topic, please
let me know.



Mon, 15 Aug 2005 06:21:59 GMT  
 Most efficient way to strip leading zeros from string
If sValue = "012345" then try this:

sValue = CStr(Val(sValue))

Actually you don't even need the CStr if sValue has been declared as
Dim sValue as String


Quote:
> Hi,

> I'm a former FoxPro programmer working on a VB utility.
> I'm hoping that somebody could suggest the best way to
> take a six character string (ie: "015676"), strip the
> leading zero(s) and end up once again with a character
> string.
> Through FoxPro I would have probably done a substr() and
> include some code to pull out everything to the right of
> the first zero in the string but I'm not very familiar
> with VB Syntax and commands yet. I am working on it
> though.....
> Any sugesstions would be greatly appreciated.

> Thanks.

> PS. If I should have posted this in another topic, please
> let me know.



Sat, 03 Sep 2005 05:21:32 GMT  
 Most efficient way to strip leading zeros from string
This method will work as long as the number is no more that 15 digits.


If sValue = "012345" then try this:

sValue = CStr(Val(sValue))

Actually you don't even need the CStr if sValue has been declared as
Dim sValue as String


Quote:
> Hi,

> I'm a former FoxPro programmer working on a VB utility.
> I'm hoping that somebody could suggest the best way to
> take a six character string (ie: "015676"), strip the
> leading zero(s) and end up once again with a character
> string.
> Through FoxPro I would have probably done a substr() and
> include some code to pull out everything to the right of
> the first zero in the string but I'm not very familiar
> with VB Syntax and commands yet. I am working on it
> though.....
> Any sugesstions would be greatly appreciated.

> Thanks.

> PS. If I should have posted this in another topic, please
> let me know.



Sat, 03 Sep 2005 05:40:48 GMT  
 Most efficient way to strip leading zeros from string

Quote:
> Hi,

> I'm a former FoxPro programmer working on a VB utility.
> I'm hoping that somebody could suggest the best way to
> take a six character string (ie: "015676"), strip the
> leading zero(s) and end up once again with a character
> string.
> Through FoxPro I would have probably done a substr() and
> include some code to pull out everything to the right of
> the first zero in the string but I'm not very familiar
> with VB Syntax and commands yet. I am working on it
> though.....
> Any sugesstions would be greatly appreciated.

ZeroString = "015676"
NoZeroString = Format$(ZeroString, "#")

Rick - MVP



Sat, 03 Sep 2005 11:47:28 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Jet Engine stripping off leading zero

2. Trim leading zeros from string

3. VsFlexGrid Pro 7: Leading zeroes are suppressed when entering a string value

4. DataReport is stripping my leading spaces...

5. DataReport is stripping my leading spaces...

6. leading zeros

7. Leading Zeros

8. Adding leading zeros ???

9. Leading zeros in minutes

10. Excel VBA - Pad SSN's w/Leading Zeros

11. Excel Xp VBA - Pad SSN's w/Leading Zero's

12. I automatically want leading zeros before a number

 

 
Powered by phpBB® Forum Software