MID$ function

Purpose: MID$ returns a substring of a string.


 Syntax:

 SubStr$ = MID$(MainStr$, Start% [, Length%])

 Parameters:

  • MainStr$ String from which SubStr$ is extracted.
  • Start% Integer specifying the start position of the SubStr$ to be extracted from MainStr$.
  • Length% [OPTIONAL] Length of the substring to be extracted. This can be omitted if all the characters to the right of Start% are to be retrieved.

 Return Value:

  • SubStr$, the return value, is a substring extracted from MainStr$.

Remarks: It is the responsibility of the programmer to ensure that the receiving string is large enough to hold the string being returned from MID$.

Example 1 :


 DIM SubStr$
 SubStr$ = MID$("abcdefg", 3, 4)
 PRINT SubStr$

Result:

cdef

Example 2:


 DIM SubStr$
 SubStr$ = MID$("abcdefg", 2)
 PRINT SubStr$

Result:

bcdefg

BCX Console Sample Programs using MID$ function.

S17.bas   S23.bas   S39.bas   S55.bas   S61.bas   S84.bas   S87.bas   S110.bas