CopyAndDelete

Top  Previous  Next

function CopyAndDelete(ByRef sSource, iStart, iLength) As String

 

CopyAndDelete is a combination of the functions Mid and Delete.

 

CopyAndDelete returns a substring containing iLength characters starting at position iStartPos while the returned string is deleted from sSource. The first character of sSource has the index 1.

 

If iStartPos is larger than the length of sSource, an empty string is returned and nothing is deleted from sSource.

 

If iLength specifies more characters than are available, only the characters starting from position iStartPos to the end of sSource are returned and deleted.

 

Parameters

 

sSource ... String expression from which characters are returned and deleted.
iStartPos ... Integer expression. Starting position of the characters to return and delete. iStartPos is one based.
iLength ... Integer expression. Number of characters to return and delete.

 

Example:

Dim s, s2

 

= "This is a text"

s2 = CopyAndDelete(s, 6, 5)

' returns s = "This text" and s2 = "is a "




Translate document: