Sub CopyAndDelete(ByRef $source As String, $start As Integer, $len As Integer) As String


CopyAndDelete is a combination of the functions Mid and Delete.


CopyAndDelete returns a substring containing $len characters, starting at position $start, and deletes the returned substring from $source. The first character of $source has the index 1.


If $start is greater than the length of $source, an empty string is returned, and nothing is deleted from $source.


If $len specifies more characters than are available, only the characters from position $start to the end of $source are returned and deleted.


Parameters


  • $source ... String expression from which characters are returned and deleted.
  • $start ... Integer expression. Starting position of the characters to return and delete. $start is one-based.
  • $len ... Integer expression. Number of characters to return and delete.


Example:

Dim $s, $s2

$s = "This is a text"
$s2 = CopyAndDelete($s, 6, 5)
' returns $s = "This text" and $s2 = "is a "