HeadingZeros Remove and Add

Adds or remove zeros at start of string
Used to clear heading zeros from string that SQL database adds
HeadingZeros_Remove to remove all heading zeros
HeadingZeros_Add to add zeros until length (TotalLeng) is reached

CodeFunctionName
What is this?

Public

Tested

Original Work
Function HeadingZeros_Remove(FromString)
Rett = ""
For I = 1 to Len(FromString)
If Not Mid(FromString, I, 1) = "0" Then
' Exit when we find first non-zero
Rett = Mid(FromString, I , 5000)
Exit For
End If
Next
HeadingZeros_Remove = Rett
End Function
Function HeadingZeros_Add(ToString, TotalLeng)
Rett = Right( String(TotalLeng, "0") & ToString, TotalLeng)
HeadingZeros_Add = Rett
End Function

FromString
or
ToString, TotalLeng

Views 2,210

Downloads 828

CodeID
DB ID