B
Barbara Brenner
Someone from this group posted a solution -- a function -- for trimming
leading zeroes. This was awhile back (1999). I just tried it and it worked
great:
Public Function StripLeadZeroes(Txt As String) As String
Dim Lgth As Integer
Dim Cnt As Integer
Dim Char As String
Txt = Nz(Txt,"") ' make sure we aren't dealing with a null value
Lgth = Len(Txt) ' get length of text string passed
If Lgth > 1 Then ' check if string is more than 1 char - if only 1 char
then there is nothing to strip
For Cnt = 1 To Lgth
Char = Mid(Txt, Cnt, 1)
If Char = "0" Then
Mid(Txt, Cnt, 1) = " "
Else
Exit For
End If
Next Cnt
End If
StripLeadZeroes = Trim(Txt)
End Function
----------------------------------------------------------------------------
------------------
But now I need to incorporate an additional process--I need to get rid of
the last 2 characters of the string as well.
Can you help?
BB
leading zeroes. This was awhile back (1999). I just tried it and it worked
great:
Public Function StripLeadZeroes(Txt As String) As String
Dim Lgth As Integer
Dim Cnt As Integer
Dim Char As String
Txt = Nz(Txt,"") ' make sure we aren't dealing with a null value
Lgth = Len(Txt) ' get length of text string passed
If Lgth > 1 Then ' check if string is more than 1 char - if only 1 char
then there is nothing to strip
For Cnt = 1 To Lgth
Char = Mid(Txt, Cnt, 1)
If Char = "0" Then
Mid(Txt, Cnt, 1) = " "
Else
Exit For
End If
Next Cnt
End If
StripLeadZeroes = Trim(Txt)
End Function
----------------------------------------------------------------------------
------------------
But now I need to incorporate an additional process--I need to get rid of
the last 2 characters of the string as well.
Can you help?
BB