Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Leading Zeros

Status
Not open for further replies.

BigglesUK

MIS
Jun 29, 2005
23
0
0
GB
Hello,

Ive got a string (its actually all numbers but its a string)

Sometimes its formatted 0004, sometimes 002 and sometimes 0000006...

basically i need to remove all leading zero's from the string.

ive been trying to use this:

Code:
numberVar loglength := Length ({VENDPACKINGSLIPJOUR.WUKLOGNUMBER});

if "00" in left({VENDPACKINGSLIPJOUR.WUKLOGNUMBER},2) then right({VENDPACKINGSLIPJOUR.WUKLOGNUMBER},loglength-2)
else {VENDPACKINGSLIPJOUR.WUKLOGNUMBER}

However can i use a for loop to work out length of string and search until it finds the first num thats not a 0 and then select the right amount - the leading zero's?

any suggestions?
 
Or to error check first and qualify it, use:

if not(isnull({VENDPACKINGSLIPJOUR.WUKLOGNUMBER}))
and
isnumber(({VENDPACKINGSLIPJOUR.WUKLOGNUMBER}) then
val({VENDPACKINGSLIPJOUR.WUKLOGNUMBER})
else
0

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top