QBasic 1.1: MID$ Statement
Explanation
MID$ Function and Statement
The MID$ function returns part of a string (a substring).
The MID$ statement replaces part of a string variable with another string.
Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Syntax
MID$(stringexpression$,start%[,length%]) |
MID$(stringvariable$,start%[,length%])=stringexpression$ |
Description / Parameter(s)
stringexpression$ |
The string from which the MID$ function returns a substring, or the replacement string used by the MID$ statement. It can be any string expression. |
start% |
The position of the first character in the substring being returned or replaced. |
length% |
The number of characters in the substring. If the length is omitted, MID$ returns or replaces all characters to the right of the start position. |
stringvariable$ |
The string variable being modified by the MID$ |
Example
a$ = "Where is Paris?"
PRINT MID$(a$, 10, 5) 'Output is: Paris
Text$ = "Paris, France"
PRINT Text$ 'Output is: Paris, France
MID$(Text$, 8) = "Texas "
PRINT Text$ 'Output is: Paris, Texas