Top  Previous  Next

function Mid(sSource As String, iStartPos As Integer, iLength As Integer) As String


' -or-


function Copy(sSource As String, iStartPos As Integer, iLength As Integer) As String


Mid returns a substring containing iLength characters starting at position iStartPos. The first character of sSource has the index 1.


If iStartPos is larger than the length of sSource, Mid returns an empty string.


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




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



Dim s, s2


= "This is a text"

s2 = Mid(s, 6, 2)

' returns s2 = "is"