Skip to main content

TrimStart

This is based on a discussion in the ideascripting forum.  This custom function will trim a certain character from a given field.  I have made it a bit more generic so you can decide what character to trim from the beginning.  I will attach the Custom Function tonight for use but this is the code:

Option Explicit
Function TrimStart(p1 As String,p2 As String) As String

 Dim i As Integer
 Dim tempString
 tempString = p1
 For i = 1 To Len(p1)
  If Mid(p1,i,1) = p2 Then
   tempString = Mid(p1,i + 1,Len(p1) - i)
  Else
   TrimStart = tempString
   Exit for
  End If
 Next i
End Function

You would call it by using #TrimStart(Character Field, Character to trim) so if you wanted to trim leading 1s from the field MY_FIELD it would be the following:

#TrimStart(MY_FIELD, "1")

As the code is in visual basic it can also be easily used in an ideascript.

Download