MidB Function

Returns a portion of a String. The first character is numbered 1.

Syntax
result = MidB( source, start, [length] )
result = stringVariable.MidB( start, [length] )

Parameters
source | String | Required. The string from which bytes are returned.
start | Integer | Required. The position of the first byte to be returned. If start is greater than the number of bytes in source, an empty string is returned.
length | Integer (Optional) | Optional. The number of bytes to return from source. If omitted, all bytes from start to the end of source are returned. If length + start is greater than the length of source, all bytes from start to the end of source will be returned.

Return Value
Result | String | The portion of source from start and continuing for length characters or all remaining characters if length is not specified.

# Notes

MidB treats source as a series of bytes, rather than a series of characters. MidB should be used when source represents binary data. If you need to extract characters rather than bytes, use the Mid function. To determine the number of bytes in a String, use the LenB function.

# Examples

These examples use the MidB function to return portions of a String.

Dim s As String
s=MidB("This is a test", 6) //returns "is a test"
s=MidB("This is a test", 11, 4) //returns "test"

# See Also

AscB, ChrB, InStrB, LeftB, LenB, Mid, RightB functions.