Delete

Top  Previous  Next

Sub Delete(ByRef $s As String, $startPos As Integer, $length As Integer)

 

Removes a substring of $length characters from string $s starting at position $startPos. The first character of $s has the index 1.

 

If $startPos is larger than the length of the string or less than 1, no characters are deleted.

 

If $length specifies more characters than remain starting at $startPos, Delete removes the rest of the string. If $length is less than or equal to 0, no characters are deleted.

 

Parameters

 

$s ... String expression from which the substring is deleted.
$startPos ... Integer expression. Starting position of the characters to delete. $startPos is one based.
$length ... Integer expression. Number of characters to delete.

 

Example:

Dim $s

 

$s = "This is a text"

Delete($s, 6, 5)

' returns $s = "This text"