Function to Replace Leading Characters of a String

Mindwatering Incorporated

Author: Tripp W Black

Created: 04/25/2003 at 03:36 PM


Notes Developer Tips
Agents, LotusScript

This function removes a leading character from a string (e.g. aaaaa535a to 535a or 000123 to 123)

If you want to just do a number and know that you have all numbers as the string. Then do the second function below.

Function TrimString(oldstring As String, charstring) As String
' this function is meant to trim and leading characters off of an existing string based number
' oldstring is original string; charstring is leading character to remove (e.g. 0s)
Dim newstring As String
Dim a As Integer
Dim b As Integer
Dim ch As String
b = 0
For a = 1 To Len(oldstring)
ch =Mid(oldstring,a,1)
If ch <> charstring Then
' Stop at the first non-zero character
Goto FoundIt
End If
newstring = Right(oldstring,Len(oldstring)-b)
If newstring ="" Then
TrimString = oldstring
TrimString = newstring
End If
End Function

Function TrimNumStr(oldstring As String)
Dim tmpnum As Long
Dim newstr As String
End Function

previous page