String Functions

From Apache OpenOffice Wiki
Jump to: navigation, search



Apache OpenOffice Basic supports several runtime functions for string manipulation. Some of the functions are explained briefly in the following:

  • Asc returns the Unicode value of the first character of its string parameter.
  • Chr returns a string containing the character that is specified by the ASCII or Unicode value passed to the function. This function is used to represent characters, such as the carriage return code (Chr(13)), that cannot be written in the "" notation. This is not necessary for the " character, which can be included in a string literal by simply doubling it, eg. s = "This string has ""embedded"" quotes"
  • Str converts a numeric expression to a string in a locale-independent manner (contrary to the CStr function).
  • Val converts a string to a numeric value.
  • LCase converts all letters in a string to lowercase. Only uppercase letters within the string are converted. All lowercase letters and nonletter characters remain unchanged.
  • UCase converts characters in a string to uppercase. Only lowercase letters in a string are affected. Uppercase letters and all other characters remain unchanged.
  • Left returns the leftmost “n” characters of a string expression.
  • Mid returns the specified portion of a string expression.
  • Right returns the rightmost "n" characters of a string expression.
  • Trim removes all leading and trailing spaces of a string expression.

All these functions are fully compatible with VBA and all functions returning a string can be specified with a trailing $ like Mid$.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages