MID$()

MID$(S,P,N)

RETURNS THE N CHARACTERS OF THE STRING S FROM THE POSITION P

  • Type: Function
  • Parameters: 3
  • Group: Strings

ACTION

The function MID$(S,P,N) returns the N characters of the string expression S from the position P.

P must be greater than 0.

N must not be negative. If N is 0, MID$ returns the empty string ("").

Remark: the keyword MID$ ends by '$' : it means that the returned value is a string.

SYNTAX: Result$=MID$(S,N,P)

  • S = string expression.
  • P = position of the first character to extract.
  • N = number of characters to be extracted from the string S.
  • Result$ is a string.

USE

  • The function MID$() is used to extract a sub-string.

ERROR

  • If S is not a correct string expression.
  • If P is not a correct expression.
  • If P is less than or equal to 0 or greater than 200.
  • If N is not a correct expression.
  • If N is less than or equal to 0 or greater than 200.

EXAMPLE

print mid$("abcdef",3,2)

print "cd"

SEE ALSO

INSERT$()

INSTR()

LEFT$()

LEN()

LOWER$()

LTRIM$()

RIGHT$()

RTRIM$()

STR$()

STRING$()

TRIM$()

UPPER$()