From QB64 Wiki
Revision as of 02:27, 19 October 2011 by imported>Clippy
Jump to navigation Jump to search

The LTRIM$ function removes leading space characters from a STRING value.


return$ = LTRIM$(value$)


  • value$ is the STRING value to trim.
  • If value$ contains no leading space characters, value$ is returned unchanged.
  • Convert fixed length STRING values by using a different return$ variable.
  • Can be used to trim the leading space of a positive numerical value converted to a string value by STR$.

Example 1: Trimming a positive string number.

value = 12345 number$ = LTRIM$(STR$(value)) 'converting number to string removes right PRINT space PRINT "[" + number$ + "]"


Example 2: Trimming leading spaces from text strings.

PRINT LTRIM$("some text") PRINT LTRIM$(" some text")

some text some text

Example 3: A TRIM$ function to trim spaces off of both ends of a string.

text$ = " Text String " trimmed$ = TRIM$(text$) PRINT CHR$(26) + trimmed$ + CHR$(27) FUNCTION TRIM$(text$) TRIM$ = LTRIM$(RTRIM$(text$)) END FUNCTION

→Text String←

See also

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page