K
Kermit Piper
Hello,
I have a function which removes ALL leading zeros, but is there a way
to remove only the FIRST leading zero? Any help would be greatly
appreciated. Below is my function to remove ALL leading zeros.
Thanks in advance, KP
Public Function RemoveLeadingZeros( _
ByVal strValue) As String
' Test if there is at least 1 leading zero
If Left(strValue, 1) = "0" Then
Do While True 'fContinue 'And (intPosition <= intLen)
If Mid(strValue, 1, 1) = "0" Then
strValue = Replace(strValue, "0", "", 1, 1, vbTextCompare)
Else
' reached the first non-zero string
Exit Do
End If
Loop
Else
' Does not have a leading zero
End If
RemoveLeadingZeros = strValue
End Function
I have a function which removes ALL leading zeros, but is there a way
to remove only the FIRST leading zero? Any help would be greatly
appreciated. Below is my function to remove ALL leading zeros.
Thanks in advance, KP
Public Function RemoveLeadingZeros( _
ByVal strValue) As String
' Test if there is at least 1 leading zero
If Left(strValue, 1) = "0" Then
Do While True 'fContinue 'And (intPosition <= intLen)
If Mid(strValue, 1, 1) = "0" Then
strValue = Replace(strValue, "0", "", 1, 1, vbTextCompare)
Else
' reached the first non-zero string
Exit Do
End If
Loop
Else
' Does not have a leading zero
End If
RemoveLeadingZeros = strValue
End Function