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

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 302 Downloads 129

'zero', 'heading', 'string', 'sql', 'database', 'zeros', 'clean', 'db', 'select', 'text', 'varchar', 'nvarchar', 'nchar'

ANmarAmdeen
549
Attachments
Texts + Strings Classic ASP
Revisions

v1.0