String Functions


Chr

Chr(Value)

Returns the character corresponding to the given ASCII/Unicode character code.

Returns: String

Examples:

Chr(65)     ' "A"
Chr(44)     ' ","
Chr(13)     ' carriage return

Decode

Decode(Value)

Decodes a previously encoded string (Base64 or similar encoding). Counterpart to Encode.

Returns: String

Examples:

Decode(EncodedField)

Decrypt

Decrypt(Value, Key)

Decrypts an encrypted string using the provided key. Counterpart to Encrypt.

Parameter Description
Value The encrypted string to decrypt
Key The encryption key

Returns: String

Examples:

Decrypt(PasswordField, "my-secret-key")

Encode

Encode(Value)

Encodes a string (Base64 or similar). Use Decode to reverse.

Returns: String

Examples:

Encode("sensitive data")

Encrypt

Encrypt(Value, Key)

Encrypts a string using the provided key. Use Decrypt to reverse.

Parameter Description
Value The string to encrypt
Key The encryption key

Returns: String

Examples:

Encrypt("my password", "secret-key")

Format

Format(Value, FormatString)

Formats a value using a .NET format string.

Parameter Description
Value The value to format
FormatString A .NET format specifier

Returns: String

Examples:

Format(3.14159, "0.00")          ' "3.14"
Format(1234567, "#,##0")         ' "1,234,567"
Format(Now, "yyyy-MM-dd")        ' "2024-06-15"
Format(0.875, "P1")              ' "87.5%"

InStr

InStr([Start,] String1, String2)

Searches for String2 within String1 and returns the 1-based position of the first match. Returns 0 if not found.

Parameter Description
Start (optional) 1-based starting position for the search
String1 The string to search within
String2 The substring to search for

Returns: Integer (1-based position, or 0 if not found)

Examples:

InStr("Hello World", "World")       ' 7
InStr("ABCABC", "BC")               ' 2
InStr(5, "ABCABC", "BC")            ' 5 (start after position 4)

InStrRev

InStrRev(String1, String2, [Start])

Like InStr but searches from right to left. Returns the 1-based position of the last occurrence.

Parameter Description
String1 The string to search within
String2 The substring to search for
Start (optional) Starting position (searches leftward from here)

Returns: Integer (1-based position, or 0 if not found)

Examples:

InStrRev("ABCABC", "BC")     ' 5
InStrRev("path/to/file", "/")  ' position of last slash

LCase

LCase(String)

Converts a string to lowercase.

Returns: String

Examples:

LCase("Hello World")    ' "hello world"

Left

Left(String, Length)

Returns the leftmost Length characters of String.

Returns: String

Examples:

Left("Hello World", 5)    ' "Hello"
Left(ProductCode, 3)

Len

Len(String)

Returns the number of characters in String. Returns 0 if the string is null or empty.

Returns: Integer

Examples:

Len("Hello")     ' 5
Len("")           ' 0

LTrim

LTrim(String)

Removes leading (left-side) whitespace from String.

Returns: String

Examples:

LTrim("   Hello")     ' "Hello"

Mid

Mid(String, Start, [Length])

Extracts a substring starting at Start (1-based). If Length is omitted, returns from Start to the end of the string.

Parameter Description
String Source string
Start 1-based starting position
Length (optional) Number of characters to extract

Returns: String

Examples:

Mid("Hello World", 7)       ' "World"
Mid("Hello World", 1, 5)    ' "Hello"

Replace

Replace(String, Find, Replace)

Replaces all occurrences of Find within String with Replace.

Parameter Description
String Source string
Find Substring to find
Replace Replacement string

Returns: String

Examples:

Replace("Hello World", "World", "There")    ' "Hello There"
Replace(csv, ",", "|")

Right

Right(String, Length)

Returns the rightmost Length characters of String.

Returns: String

Examples:

Right("Hello World", 5)    ' "World"
Right(AccountNumber, 4)

RTrim

RTrim(String)

Removes trailing (right-side) whitespace from String.

Returns: String

Examples:

RTrim("Hello   ")    ' "Hello"

Space

Space(Number)

Returns a string consisting of Number space characters.

Returns: String

Examples:

Space(5)         ' "     "
"A" & Space(3) & "B"    ' "A   B"

Split

Split(String, Separators)

Splits String into an array of substrings using the specified separator characters.

Parameter Description
String The string to split
Separators Separator string (each character acts as a delimiter)

Returns: String() (array of strings)

Examples:

Split("A,B,C", ",")          ' ["A", "B", "C"]
Split("one two three", " ")  ' ["one", "two", "three"]

Access elements by index:

Dim parts = Split("2024-06-15", "-")
Dim year = parts(0)     ' "2024"
Dim month = parts(1)    ' "06"

StrReverse

StrReverse(String)

Returns String with its characters in reverse order.

Returns: String

Examples:

StrReverse("Hello")    ' "olleH"

SubString

SubString(String, Start, [Length])

Extracts a substring using 0-based indexing (unlike Mid which is 1-based).

Parameter Description
String Source string
Start 0-based starting position
Length (optional) Number of characters to extract

Returns: String

Examples:

SubString("Hello World", 6)       ' "World"
SubString("Hello World", 0, 5)    ' "Hello"

Trim

Trim(String)

Removes both leading and trailing whitespace from String.

Returns: String

Examples:

Trim("  Hello  ")    ' "Hello"

UCase

UCase(String)

Converts a string to uppercase.

Returns: String

Examples:

UCase("Hello World")    ' "HELLO WORLD"