Strings

This module provides a number of string manipulation routines.

Len

Function Len(value As String) As Byte
  • value - Input string. Can be either a variable, constant or string expression.

Return the length of a given string. For example:

dim strLen as byte = Len("hello world!") ' result = 12 

InStr

 Function InStr(str As String, subStr As String) As byte
  • str - Input string to check against. Can be a variable, constant or string expression.
  • subStr - The string value to search for. Can be a variable, constant or string expression.

Returns the starting position of a sub string within a string. If the sub string cannot be found, the function returns zero. For example:

dim myString as string = "this is hello"
dim pos as byte = InStr(myString, "hello") ' result = 9

LCase

 Function LCase(value As String) As String
  • value - Input string. Can be a variable, constant or string expression.

Return the input string as lowercase characters. For example:

dim myString as string = "FIREWING"
myString = LCase(myString) ' result = "firewing"

UCase

 Function UCase(value As String) As String
  • value - Input string. Can be a variable, constant or string expression.

Return the input string as uppercase characters. For example:

dim myString as string = "firewing"
myString = UCase(myString) ' result = "FIREWING"

LTrim

 Function LTrim(str As String) As String
  • str - Input string. Can be a variable, constant or string expression.

Return the input string with all leading space characters removed. For example:

dim myString as string = "   firewing"
myString = LTrim(myString) ' result = "firewing"

RTrim

 Function RTrim(str As String) As String
  • str - Input string. Can be a variable, constant or string expression.

Return the input string with all space characters at the end of the string removed. For example:

dim myString as string = "firewing   "
myString = RTrim(myString) ' result = "firewing"

Trim

 Function Trim(str As String) As String
  • str - Input string. Can be a variable, constant or string expression.

Return the input string with all space characters at the beginning and end of the string removed. For example:

dim myString as string = "   firewing   "
myString = Trim(myString) ' result = "firewing"

Left

 Function Left(str As String, length As Byte) As String 
  • str - Input string. Can be a variable, constant or string expression.
  • length - Number of characters to extract.

Returns a string containing a specified number of characters from the left side of a string. For example:

dim myString as string = "abcdefg"
myString = Left(myString, 3) ' result = "abc"

Mid

 Function Mid(str As String, start As Byte, Optional length As Byte = &HFF) As String
  • str - Input string. Can be a variable, constant or string expression.
  • start - Start position of string to extract. The first chacter of a string is indexed at zero.
  • length - Number of characters to extract.

Returns a string containing a specified number of characters from start to start + length. For example:

dim myString as string = "abcdefg"
myString = Mid(myString, 2, 2) ' result = "cd"

Right

 Function Right(str As String, length As Byte) As String 
  • str - Input string. Can be a variable, constant or string expression.
  • length - Number of characters to extract.

Returns a string containing a specified number of characters from the right side of a string. For example:

dim myString as string = "abcdefg"
myString = Right(myString, 3) ' result = "efg"

Space

 Function Space(number As Byte) As String
  • number - Number of space characters to generate.

Generates a string of spaces, up to a maximum of 24 characters. For example:

dim myString as string 
myString = Space(5) ' result = "     "

StrDup

 Function StrDup(number As Byte, character As Char) As String
  • number - Number of characters to generate.
  • character - The character to duplicate. Can be a variable or constant.

Generates a string of characters, up to a maximum of 24 characters. For example:

dim myString as string 
myString = StrDup(5, "x") ' result = "xxxxx"

StrReverse

 Function StrReverse(expression As String) As String
  • expression - Input string. Can be a variable, constant or string expression.

Reverses all the characters in a string. For example:

dim myString as string 
myString = StrReverse("abcdefg") ' result = "gfedcba"