Removing leading zero's using InStr

Howlsta

Vampire Slayer
Local time
Today, 19:57
Joined
Jul 18, 2001
Messages
180
Greetings Folks!

I'm trying to write code to remove zero's from the start of a road number. The problem is that there are normally between 1-3 zero's at the start, so i'm not sure now to set up the expression sought. I then want to "trim" off the zero's. Anyway I'm having problems achieving the first bit, I think it is probably easy if you know now.

Any Ideas?

Rich
 
If the road number is only a number, make the field a number (not text) and the leading zero's will be removed.

Col
 
The problem is not that simple unfortunately ):
I'm running some code that checks a another field (road type), depending on the integer in the road type field the code adds a letter in front of the road number, eg M (motorway) A,B,C or nothing if it is not classified. The data can then be imported into Access, the code is supposed to put the data in the correct format for the import.
 
If the thing you are working on is numeric, you might try something like this...

Assume the thing to be "de-zeroed" is in stData

If IsNumeric(stData) then

stData = CStr( CLng( stData ) )

end if

That double conversion should do the trick because the CStr will not restore the leading zeros removed by the CLng function.
 
Thanks Doc,

The double conversion did exactly what you said.

Cheers

Rich
 

Users who are viewing this thread

Back
Top Bottom