Chilkat VB.NET StringArray Class Reference

StringArray

* This is a freeware class/component/library.

Component for managing and manipulating collections of strings.

Object Creation

(C#)
Chilkat.StringArray obj = new Chilkat.StringArray();
(VB.NET)
Dim obj As New Chilkat.StringArray()

Properties

Count As Integer (ReadOnly)

The number of strings in the array.

Crlf As Boolean

If true, strings are always automatically converted to use CRLF line endings. If false, strings are automatically converted to use bare LF line endings.

Length As Integer (ReadOnly)

The number of strings in the array. (Identical to the Count property.)

Trim As Boolean

If true, whitespace, including carriage-returns and linefeeds, are automatically removed from the beginning and end of a string when added to the array.

Unique As Boolean

If true, the array does not allow duplicates. When an attempt is made to insert a string that already exists in the array, the insertion simply doesn't happen and no error is returned.

Methods

Sub Append(ByVal str As String)

Appends a string to the end of the array.

Function AppendSerialized(ByVal encodedStr As String) As Boolean

Appends multiple strings to the end of the array. The encodedStrings argument is what is returned from the Serialize method (see below).

Function Clear() As Boolean

Remove all strings from the array.

Function Contains(ByVal str As String) As Boolean

Returns true if the string is present in the array. The string comparisons are case sensitive.

Function Find(ByVal str As String, ByVal firstIndex As Integer) As Integer

Finds the index of the first string equal to the string passed. The search begins at beginIndex. If the string is not found, -1 is returned. The first string in the array is at index 0.

Function FindFirstMatch(ByVal str As String, ByVal firstIndex As Integer) As Integer

To be documented soon...

Function GetString(ByVal index As Integer) As String

Returns the string at a location in the array. The first string is at index 0.

Returns Nothing on failure

Function GetStringLen(ByVal index As Integer) As Integer

Returns Nth's string length, in characters. The first string is at index 0.

Sub InsertAt(ByVal index As Integer, ByVal str As String)

Insert a string into the array at a particular index. Using index 0 will insert at the beginning.

Function LastString() As String

Returns the last string in the array.

Returns Nothing on failure

Function LoadFromFile(ByVal filename As String) As Boolean

Adds strings from a file (one per line) into the string array.

Returns true for success, false for failure.

Sub LoadFromText(ByVal str As String)

Adds strings from an in-memory string (one per line) into the string array.

Function Pop() As String

Returns the last string and removes it from the array.

Returns Nothing on failure

Sub Prepend(ByVal str As String)

Adds a string to the beginning of the array.

Sub Remove(ByVal str As String)

Removes all strings equal to the string argument from the array.

Function RemoveAt(ByVal index As Integer) As Boolean

Removes the string at a particular index.

Function SaveNthToFile(ByVal index As Integer, ByVal filename As String) As Boolean

Saves the Nth string in the StringArray object to a file.

Returns true for success, false for failure.

Function SaveToFile(ByVal filename As String) As Boolean

Saves the array of strings to a file, one string per line.

Returns true for success, false for failure.

Function SaveToText() As String

Saves the array of strings to a single string, one string per line (separated by CRLF line endings).

Function Serialize() As String

Returns an string which is an encoded representation of all the strings in the array. The StringArray can be re-created by calling the AppendSerialized method. One reason this method exists is to make it easy to pass entire string arrays as a form parameter in a Web page.

Returns Nothing on failure

Sub Sort(ByVal ascending As Boolean)

Sorts the string array in ascending or descending order.

Sub SplitAndAppend(ByVal str As String, ByVal boundary As String)

Splits a string at a character or substring boundary and adds each resulting string to the StringArray object.

Sub Subtract(ByVal sa As StringArray)

Subtracts the strings in the argument object from the calling object's set.

Sub Union(ByVal array As StringArray)

Performs the union set-operator. The caller will contain the union of two string arrays.