MID(string, start [,length])

Returns the text string which is a substring of a larger string (String).


stringThe text string (String).
startThe character position to start (Long).
length(Optional) The number of characters to return (Long).

REMARKS
* If "start" > Len("string"), then a zero length string is returned.
* The first character position is 1.
* If "string" is Null, then Null is returned.
* If "length" is left blank, then all the characters from the "start" to the end of "string" are returned.
* You can use the MIDB function that can be used with byte data ??
* You can use the MID$ function to return a String data type instead of a Variant/String data type.
* You can use the MIDB$ function to return a String data type instead of a Variant/String data type.
* You can use the MID - Statement to replace a specified number of characters.
* The equivalent Excel function is Application.WorksheetFunction.MID
* The equivalent .NET function is Microsoft.VisualBasic.Strings.Mid
* For the Microsoft documentation refer to docs.microsoft.com

Mid("hello world", 1) = "Hello World" 
Mid("hello world", 2) = "ello World"
Mid("abc",3) = "c"
Mid("somemoretext", 5000, 1) = ""

Mid("somemoretext", 1, 1) = "s"
Mid("somemoretext", 2, 1) = "so"
Mid("somemoretext", 5, 4) = "more"

Dim sString As String
sString = "123456789"
Debug.Print Mid(sString, Len(sString) - 1) = "89"
Debug.Print Mid(sString, Len(sString) - 2) = "789"
Debug.Print Mid(sString, Len(sString) - 3) = "6789"

Strings.Mid("123456789",Strings.Len("123456789", 3) = "7"

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top