|
|
SynopsisThe Val() function will ignore leading zeroes and return the numerical value of a string. But what if you are dealing with an alphanumeric string and would like to preserve the other characters while trimming the leading zeroes? CODE ' TrimLeadingZero
' http://www.utteraccess.com/wiki/index.php/TrimLeadingZero ' Code courtesy of UtterAccess Wiki ' Licensed under Creative Commons License ' http://creativecommons.org/licenses/by-sa/3.0/ ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' rev date brief descripton ' 1.0 2010-09-11 This function uses recursion to trim the leading zeroes and returns the rest of the string. ' Public Function TrimLZ(ByVal strLZ As String) As String If Left(strLZ, 1) = "0" Then TrimLZ = TrimLZ(Mid(strLZ, 2)) Else TrimLZ = strLZ End If End Function
|
| This page was last modified 09:06, 6 April 2011. This page has been accessed 833 times. Disclaimers |