Skip to content

String.PadStart

boxgaming edited this page Aug 5, 2025 · 1 revision

Pads a string with a given string (repeated and/or truncated, if needed) so that the resulting string has a given length. The padding is applied from the start of this string.

Syntax

result$ = String.PadStart (s$, targetLength% [,__padStr%_])

Parameters

  • The s$ parameter contains the string to pad.
  • targetLength% specifies the length of the resulting string once the current str has been padded.
  • The optional padStr$ parameter contains the string to pad the current s$ with. If padStr$ is too long to stay within targetLength%, it will be truncated from the end. The default value is the space character.

Example

Import String From "lib/lang/string.bas"

Print String.PadStart("9302", 8, "0")

Output

00009302

See Also

String.PadEnd
Javascript - String.padStart()

Clone this wiki locally