[blue]
Function StripleadingZeros(Dataval As String) As String
Dim ReturnedString As String
Dim LastDigitNotZero As String
Dim PosLastdigitNotzero As Integer
Dim NumOfEndingZerosToAdd As Integer
[black]
'check for number Ending Zeros which will need to be
'replaced
[/black]
LastDigitNotZero = Left(StrReverse(Trim(Replace(Dataval, "0", Chr$(32), 1))), 1)
PosLastdigitNotzero = InStr(1, StrReverse(Dataval), LastDigitNotZero)
NumOfEndingZerosToAdd = PosLastdigitNotzero - 1
[black]
'Clear ALL Zeros & Trim away spaces
[/black]
Dataval = Trim(Replace(Dataval, "0", Chr$(32), 1))
[black]
'Replace spaces that should be zero & Replace Ending Zeros
[/black]
ReturnedString = Replace(Dataval, Chr$(32), "0", 1) & String(NumOfEndingZerosToAdd, "0")
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.