G
Guest
Is there a function that would identify and strip leading zeros from a text
string? The number of leading zeros will vary.
string? The number of leading zeros will vary.
Is there a function that would identify and strip leading zeros from a text
string? The number of leading zeros will vary.
Thanks for the reply - I wasn't specific enough. C(Lng) would be plenty long
enough for me, but the problem is the field has a mix of both numeric and
alpha characters as text, for example:
EmplID
VNGL04
001352
I need to remove the leading zeros from the numeric string only. VNGL04
would stay as is, but 001352 would be converted to 1352. Any ideas on that
one?
John Vinson said:Thanks for the reply - I wasn't specific enough. C(Lng) would be plenty long
enough for me, but the problem is the field has a mix of both numeric and
alpha characters as text, for example:
EmplID
VNGL04
001352
I need to remove the leading zeros from the numeric string only. VNGL04
would stay as is, but 001352 would be converted to 1352. Any ideas on that
one?
How about 003ABC? Should that become 3ABC?
If not: update to
IIF(IsNumeric([field], CStr(CLng([field]), [field])
If so:
Public Function StripZero(strIn As String) As String
Dim iPos As Integer
iPos = 1
Do While Mid(strIn, iPos, 1) <> "0"
iPos = iPos + 1
Loop
StripZero = Mid(strIn, iPos)
End Function
Update the field to StripZero([field]).
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
I believe there's an error in John's code.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.